ASP.NET MVC2 CategoryTree Routing - asp.net

I have in SQL DB table:
Categories:
int CategoryID
int ParentID
string Name
I want make link somelike this : localhost://(Name)/(Name)/(Name) and the last (Name) is selected category.
Real example: localhost://Sports/Vodni-Polo/Balls
Problem: in DB is name of category Vodni-Polo is Vodní pólo. On link creating i translate name to SEO link shape (Vodni-Polo).
How i can get category id wihout sending extra get parametr (Sports/Vodni-Polo/Balls/?categoryId).
I get Full tree of category from DB all time, but i must know witch items i can display it.
What i want: If i click at category, send GET req.(localhost://Sports/Vodni-Polo/Balls) a from this i want know whot id have (Balls)

You can make the Name a Unique key so you can query by it and guarantee uniqueness. Alternatively a common solution is to do something like {controller}/{action}/{Name}-{Id}

Related

How to save an untouched new record

after reading a lot in this forum (and also in others), I still haven't found a solution for my problem. It's a classical scenario : a Customer creates an Order, which in turn has OrderItems.
So my tables are as follow :
tbl_Customer
cust_Id as Long (primary key, autoincrement)
cust_Name as String
cust_Adress as String
cust_Phone as String
etc
tbl_Order
ord_Id as Long (primary key, autoincrement)
ord_CustId as Long (references as foreign key field cust_Id in table tbl_Customer)
ord_Date as Date
tbl_OrderItem
oi_OrdId as Long (references as foreign key field ord_Id in table tbl_Order)
oi_ArtId as Long (references as foreign key field art_Id in table tbl_Article which is not relevant in this scenario)
oi_Count as Integer (quantity of article(s))
oi_Price as Double (price of article)
As you can see it is a not so complicated m:n relationship between customers and articles which are ordered.
Beside these tables I created in Access a form frmCustomer (based on tbl_Customer) which owns a subform frmOrder (based on tbl_Order). These two forms are connected by fields cust_Id and ord_CustId.
SubForm frmOrder in turn has a subForm frmOrderItem (based on table tbl_OrderItem). They are connected by fields ord_Id and oi_OrdId.
Some example data inserted in these tables are shown correct. Switching customers results in showing its orrders and orderitems. So far so good.
Now I want to insert a new order, and adding some orderitems to it.
If I click on button "New empty record" (record-navigation pane) of subForm frmOrder, a new empty order-record is created with empty fields and empty subform orderitem.
When I now insert a new orderitem and try to store it, an error message appears, saying the record cannot be stored because field oi_OrdId cannot be null.
That's true, because the order-record is not yet stored, and hence autoincremented field ord_Id is not yet filled. Only if I edit a field in the until now untouched order-record (for example orderdate) and leave that field, the record is stored, and the field ord_Id is filled, and also field oi_OrdId in form frmOrderItem.
But, because the fields ord_CustId (=[Forms]![frmCustomer]![cust_Id], value copied from parent form frmCustomer) and ord_Date ( =Date() ) have default-values, I don't want to edit a field first.
I would like to enter immediatly orderitems.
Is there an event (-procedure) I can use to save the untouched order-record (how ?) automatically, when I enter a field of subform frmOrderItem ?
Or has somebody of the community a helpful solution ?
And by the way, is there a way to access a new, not yet saved record ?
Thank you very much in advance for your help
ulofb
Now I want to insert a new order, and adding some orderitems to it. If
I click on button "New empty record" (record-navigation pane) of
subForm frmOrder
Don't. Do it the other way round. Block record inserts in the subform for a new order record. After insert/save of the order form, enable record inserts in the subform.

how to send emails to users in data type in PEGA

i have a data table with employee info namely id, name, company, salary and emailaddress. i want to send emails to employees with salary greater than an amount using an activty. please help me with steps.
I have tries obj browse with select salary>amount-> then loop through embedded pages and then tried to property-set .emailid(property to store emailid from table) = pxresult().emailaddress. But the problem is pxresult(x) contain only salary property because of select condition, I don't know how to get the emailid property from table.
Help is very much appreciated.
In the Obj-Browse method you can add all properties. You can include emailaddress property as well.
Check below example
Now you can do pxresult().Email property.

Google App Maker Query Builder

Created a simple app to keep track of the company fax numbers. In my header I have a search box where I want user's to search either by First Name, Last Name or both First and Last Name. I added the below to Query Builder
firstName contains? :SearchText or
lastName contains? :SearchText
Searching by first name or last name works just fine. How can I search by both first and last name? Right now when I search by both I get no results. Thanks.
"User Picker" widget should be a good fit for your case.
If you want to keep custom employees model please consider the following options:
Add Name field ("FirstName LastName") so contains operator would give expected result
Switch datasource to Query Script and process search query
(https://developers.google.com/appmaker/models/datasources#query_script)

How do I get Group ID as context in Views Drupal 7 without Panels

I have been banging my head all day with this. I have seen other posts, but they all seem to say "Use Panels" and I dont want to make a panel page for every view.
I am using Drupal 7.x, Organic Groups with Group Context, and Views.
I created a content type as a Group, and several content types as Group content types.
In my view, I added the relationships Group Membership:Node group membership, Group: Node, and Content:Author. I have tried various Contextual filters, but none seem to be working.
The view is display type page, with a path of node/%/content/documents (documents is the content type where I want to show all uploaded documents for a particular group).
What is see is whenever I add a contextual filter, the query contains a line similar to WHERE ((og_node.gid = 'xx')) and the value there is the value of the group node entity ID, and not the GID. I have set the default value on the contextual filter to "current OG Group from context" and I have set the validation criteria to validate on the Content ->group content type, and Node ID. I can get the Page Display title to use the %1 placeholder to accurately grab the Group Node title successfully, but I cant get context to be passed in so the WHERE clause contains the GID and not the entity id.
Any help?
I just tried this and the following two settings worked for me:
Relationship of Group membership: Node group membership
Contextual filter of (group membership) OG membership: Group gid
In the preview window, when I enter in the gid for the contextual filter, I get back exactly the nodes belonging to that group that I expect.
Have you tried that one yet?
You can try the og_context module (part of og)

Coding practice: how to avoid hard coding?

I have a table in the database that store 4 category and the structure of the table is ID (GUID), description. I load the category into a dropdown list (asp.net webform) to allow people to select a category and based on what they selected. I'll then display info associated with their selection and hide the others.
Currently, i do a "select case" based on the GUID that i hard coded in code behind to display the associated info. Is there a better way to do this without hard code in GUID on the code behind?
What is the Data that's associated with the Guid/Description...
The data you've hardcoded sound's like a candidate for being added to the database itself.
If it's one piece of information per Category/Guid, then consider extending your Database Table to store that info to.
If it's multiple piece of information per Category/Guid, then consider creating a new Table With a CategoryID on it, and a foreign key relationship between your Category Table and your ExtraInfo table
You could query the database for the GUIDs when the app starts and cache them in a static Dictionary.
you could store the GUID in your web-config and load it at run time. then, you can easily replace that GUID with another w/o having to recompile.
You should have a Categories table and a Posts table (or whatever it is that you will tag with your categories). In the Posts table you have a column for the CategoryID (assuming each post can only belong to one category), so that you only have the category name in one place (normalize your data).
When you render the dropdownlist, you select the GUID:s from the database. No hard coding, and if you add another category (or remove one) the dropdownlist will automatically reflect the available categories.
If you bind the dropdown list to the Category row or a Tuple that contains the category name and the value you can load the Guid in your codebehind using the SelectedValue property. You will then set the DataTextField and DataValueField on the Dropdownlist.

Resources