Web navigation to an entity - newmips

I have an newMips application deployed which I can access with myname-myapp.newmips.cloud/ as explained on this question.
Is there a url to open directly on an entity ? I am thinking of typing https://myname-myapp.newmips.cloud/employee and having the list of employees displayed in the browser (after authentication if I am not yet).
If we go one step further, https://myname-myapp.newmips.cloud/employee?id=employeeId would display this employee data sheet.

Entity show page :
https://myname-myapp.newmips.cloud/employee/show?id=employeeId
Entity list page :
https://myname-myapp.newmips.cloud/employee/list
You only need to add /show to the url to be on an entity record, /list to list records

Related

Sitecore - WFFM : Link contact facet with user profile field

I'm working on a Sitecore 8 Update 2 site.
I'm also using the web forms for marketers.
I've set up a login and register form using WFFM. I was able to link fields on the form with the fields of the user profile ( the one used in User Management )
However when i want to make a "Update Contact Details" i can't link the fields on the form with the profile fields as before. Now i have to select a "contact facet". I added one of these and WFFM picked up on this, so now i can link the field on the form with a facet.
The last link i'm missing is linking this facet ( stored in Analytics - MongoDB ) to the profile field.
Does anyone know how to achieve this ?
Bonus: This started off as a slighty different question, you can read more about this issue here:
How to update sitecore user with webforms for marketers ( Update Contact Details )
First you need to add the Create User Save Action and setup the email address as the username.
Then you need to add the User login Save Action straight after that. This is because the Update Contact Details Save action only applies to logged in users.
Then you can use the Update Contact Details Save Action. This action will create data in MongoDB under the logged in user name - so if you go to the Identifiers collection MongoDB a new entry will be created (See screen shot below).
So in short the aspnet_membership data and the MongoDB data is linked via the username in WFFM. In aspnet_users - UserName and in MongoDB by way of an identifier. You can't mix the MongoDB and aspnet_profile data they belong in two separate places.
So once you have created this user in WFFM you could call up their details using the analytics API using the identifier:
Tracker.Current.Session.Identify(username);
var personalInfo = Tracker.Current.Contact.GetFacet<IContactPersonalInfo>("Personal");
Hope that makes sense :)

Ember CLI - Custom routing for very basic dropdown

New to ember and ember cli, and not having any JS based framework experience apart from jQuery (which is not a framework)
I find my self stuck at the very beginning compared to work done in Angular,
I have a static list of groups which are on REST api `http://localhost:8000/api/groups' and it is only 8 items there, I needed to show them as dropdown for a search criteria. Nothing fancy
I started with creating a route and model with the name of groups but app stopped working and I had to create a model for group which is identical to groups model, only having 2 items for dropdown
Now i have a url in my ember app http://localhost:4200/groups which I dont need and i dont want it to be there,
But I ignored it and had to create a dropdown of the cities, api is
http://localhost:8000/api/cities <-- All cities list, needed for admin
http://localhost:8000/api/cities/active <-- For clients to show active cities so they can add their records
http://localhost:8000/api/cities/filled <-- For users, to show them where clients are available
So in ember, I created a route and model for cities, and same model is copied as city just to show the list of cities in dropdown, I needed to show cities which are filled, I had created ember g route city/filled and it created folders, but its model is also same like other two models.
Ajax call is not being sent to city/filled url and now I ended up having
http://localhost:4200/cities // useless for me
http://localhost:4200/cities/filled //useless for me
and in filled i see that ajax call is made but to the http://localhost:8000/api/cities two times, loading same data. I tried adding a dropdown on my application and opened http://localhost:4200/cities/filled in browswer, and woosh, it send ajax call to the same url 3 times, one for application.hbs and one for cities.hbs and one for city/filled. Why load the same data 3 times if it is already fetched from same url within single request?
in angular I just call a custom url and I can get the data, but for ember its really hard to get grip on these small things and there is no help around
active and filled are filters for your cities resource and these are not standalone resources, so you should try to use them as query parameters. like
http://localhost:8000/api/cities?type=filled
http://localhost:8000/api/cities?type=active
Facebook uses this style for query params. You can also use query params for getting paginated data of a resource, like for 1st page and 25 records per page, the request will look like:
http://localhost:8000/api/cities?page=1&records=25

Web.api Get method to show only selected properties from entity

Let's say I have 3 entities: Advert, User and UserRole. And in Web.Api project GetAllAdverts method.
public IEnumerable<Advert> GetAllAdverts()
{
return repository.GetAll<Advert>();
}
When i enter url ../api/advert I get JSON with all Adverts and data about adverts, but I get all data about user and user role too.
How can I get for example all advert data and only UserName form entity User ?
Is this done by creating DTOs ?
Thanks in advance !
Using DTO's is usually a good idea. It is more work, but it gives you full control and it abstracts out peculiarities of a specific data layer.
In your case, if you really only want UserName you even have to use a DTO, because it is impossible to partly load the User as navigation property from Advert.
If it does not matter that you see all properties of User except its navigation properties (like role), you may also consider to (temporarily) turn off lazy loading for the context in the repository and eager load Advert.User by using Include.

How to load or save Doctrine associated entity into Zend_Auth session

I am looking for some good solutions for a problem.
I am usig Doctrine 2.1 integrated to Zend Framework. I am using Zend_Auth with Zend_Auth_Storage_Session where I have stored User's entity. But entity of User is associtad to other Entity => AclRole. Each User has one AclRole.
For the first time, when I load user throught EntityManager, the AclRole is loaded as soon as call it in User. But when other page is loaded and entity of User is loaded from session, her 'locale' attribute is NULL.
Is there any good solution of this?
I have an excellent solution, that i am using in my project, i will send you the github link when i've checked in my code today ;)

ASP.NET MVC passing data between forms

Im pretty new to ASP.NET MVC, trying to figure out my way around.
Currently i return a ViewModel which has a IEnumeable Events as its only property. This ViewModel is StronglyTyped to a UserControl which dislays the IEnumable Events in tabular form.
One of the properties of the Event Model is an XElement, which contains some XML loaded from the DB.
Now i've added a link to the end of the tablular data to be able to view the XML in a separate page. How do i pass this data to another page for viewing?
I would post a request back to the server with some sort of Id for the Event-object and have the receiving end send back the XML related to that Id.
if you're looping through the Event objects in your IEnumerable, you can do something like:
<%= Html.ActionLink("GetXml", "Events", new { id = currentEvent.Id }) %>;
Now create an Action on your EventsController (given that you have one) like so:
public ActionResult GetXml(int id)
and retrieve the XML to pass back to the View
There are basically two ways of bringing data from one page to another using ASP.NET MVC (or any other language/framework which follows the HTTP protocol):
Sessions: Use a session to store the data you need, and load it back up at the next page.
Post the needed data back to the server. This way, the server can hold it and display it on the next page. Posted data usually comes from input or textarea elements. If you use input type="hidden" you can give it a value which represents your data. This way, you can post it back and forth till you arrive where you want.
Besides what Arve is advising, you could also consider TempData.
If you use the Get-Post-Redirect/Forward concept for you app, you could do something like:
GET - Initial Request comes in, Server responds with View and model data. User selects an item which leads to ...
POST - User selects one of the items from #1, triggering a post. That particular item can be fetched from repository, placed in TempData and then...
REDIRECT/FORWARD - The redirect collects the information out of TenpData and uses it as the model for the new View.
here is an example http://www.eworldui.net/blog/post/2008/05/08/ASPNET-MVC-Using-Post2c-Redirect2c-Get-Pattern.aspx