Blackberry - How to get Category of BlackBerryContact? - blackberry

I have not found any fields in JDK 5.0.0 for getting Category of BlackBerryContact.
If there are any alternative way for getting Category of BlackBerryContact then please suggest....

try PIMItem.getCategories()
public String[] getCategories() - Gets all the categories to which this item belongs. If there are no categories assigned to this item, a zero length array is returned.

Related

How get an parent id in HasMany field Laravel Nova

i have Category resource which have a nested Items resources via HasMany field
public function fields(Request $request)
{
return [
new Panel('Items', [
HasMany::make('Items', 'items')
]),
];
}
I need to perform specific validation with Items: the Category have integer field max_default_items so when creating a new Item inside the category i need to check, does max_default_items is greater than the actual count of items with is_default flag. The problem is that i have no idea how to get the Category id inside Item
Is it possible to pass params to HasMany field and get it inside Items resource?
Please help!

Reach the count of joined objects (sub-query) in the View in ASP.NET MVC with Entity Framework

In the Index page that shows all offers, I am trying to get the count number of all customers joined to each specific offer, I am use below in the view :
Joined Customers : #item.OfferCustomerTBLs.Count()
But it return me error :
Value cannot be null.
So, Please inform me how to use the count of joined objects of customers, and when null show nothing ?
The problem were in Controller, I have to include the joined objects as :
public ActionResult Index()
{
return View(offersTBLs.Include(y=>y.OfferCustomerTBLs).ToList());
}
Thanks for all who tried to help and Thank you Mairaj Ahmad

how to remove the collection from modelstate MVC

I have a class Person. Which is associated with the Students. now students class contain a datefield "CreatedOn".
class Person
{
String Name;
List<Student> students;
-----rest of props and methods
}
class Student
{
DateTime CreatedOn;
DateTime UpdatedOn;
---------rest of props and methods
}
now my problem is I want to remove these dates (of student class) from modelstate while updating object of person class. How can I do that?
since a person can have 2 student and other can have any number of students.
if I need to remove "Name" from ModelState I would have used ModelState.Remove("Name") for person
but how can I do it for students of person. Is there something like ModelState.Remove("students") or
ModelState.Remove("students[0]") etc?
Please help me with example
I had answered similar question before here
For those who can't afford one extra click to visit the link
Ignore other properties(other than UserInfo) : ModelState.IsValidField(UserInfo)
Clear/Remove property error : ModelState["ExtraInfo"].Errors.Clear();
Create custom validator, as also suggested by ataravati : MVC Custom validation attribute
Option 1 and 2 will work only when client side validation is disabled.
Add two viewmodels one for update action and one for create action and exclude createdon and updatedon properties from the viewmodels,
This way you keep your controllers clean from additional complexity of clearing or adding errors and just test for ModelState.IsValid.
If valid then update or create the Student with updatedon or createdon respectivily.

Lucene Search Sorting

I need to search member's by first name and last name, which I have done successfully.
Next thing which I have to do is that member's connection should come first in the list (sorting by connection.), like in Facebook, friends come first in the list and than other users of the community.
I am using grails plugin Searchable. One simple way to do this is to sort the searchListFromSearchable w.r.t. connection's list.
Following is the domain structure.
class Member extends {
String firstName
String lastName
static searchable = {
analyzer "simple"
only = ['firstName', 'lastName']
firstName boost: 5.0
}
static hasMany = [connections: Connection]
}
And Connection class is as follow
class Connection {
String uuid
Member connectedMember
static belongsTo = [member: Member]
}
Is there any lucene way to do this ?
I think you can add the sort process in the collect step or score step in Lucene. I think you get the relationship first, and when search the member, you can check whether the member is in the relationship or not. If the member is in the relationship, you can add score of this doc, such as write your own collector which extend TopFieldDocCollector and add score *= 10f before super.collect() in the collect method .
On of the solution to add friends ids to index. In this case, your search query should have followed form +name:firstName +name:lastName friend:userId^10. The friendId has a bigger boost and will cause friends to a high rank in your query.

.net MVC 3 displaying values in a many-to-one virtual object

I'm creating an expense report project - my first using MVC.
This is a Database First project and I'm using Oracle ODP.
I have an entity model with the following classes:
ExpenseReport
ExpenseItem
ExpenseType
The expense report will have many expense items.
Each expense item will be of a specific expense type from the list of types in that ExpenseType class - thus a many-to-one relationship.
A single expense type record contains for each type a category, and headings for description/comment field to go with that type.
In my view, I am able to display the report with a list of all the expense items for that report. I am doing this through my Edit or Details controllers with the following code:
public ActionResult Details(long id)
{
using (var db = new Entities())
{
var thisReport = db.ExpenseReport.Find(id);
thisReport.expItems = db.ExpenseItem.Where(e => e.BB_EXPREPORT_ID == id).ToList();
return View(thisReport);
}
}
I tried adding this to the code (just above the return View line) to also include the expense type values (category, headings) for each type but it is failing due to a casting issue - cannot implicitly convert (are you missing a cast?)
foreach (ExpenseItem item in thisReport.expItems)
{
item.expType = db.ExpenseType.Where(e => e.BB_EXP_TYPE == item.BB_EXP_TYPE);
}
My questions:
Isn't there a way I can set up my model classes so that I don't need
to add these statements? I.E. Can't I modify the virtual object Get
statement to pull them there? Or can I modify the entitymodel file
to get these values? Is it a loading issue? I turned off lazy
loading.
If there is not a way to do this at the model level so that virtual
objects are included in the get, then how can I set the cast in my
code above to pull the values from the ExpenseType table for that
given expense type?
Thanks.
Admittedly, I'm not sure of what you're trying to do, but it looks like you just want to load up your object all at once. You can do this with Entity Framework using the Include method.
I'd assume you're using the "pluralization" feature for naming your db sets, but then again, your call to "db.ExpenseReport" is missing an (s) at the end.
public ActionResult Details(long id) {
using (var db = new Entities()) {
ExpenseReport thisReport = db.ExpenseReport.Include("ExpenseItems.ExpenseType").Single(id);
return View(thisReport);
}
}
Then you can use it in your Razor view like so.
<ul>
foreach (var item in Model.ExpenseItems) {
<li>Name: #item.YourExpenseItemName - Type: #item.ExpenseType.YourTypeName</li>
}
</ul>

Resources