public UserModel Create(User user, bool includeContactGroups) { var result = new UserModel(); result.Id = user.Id; result.URL = _urlHelper.Link("User", new {id = user.Id}); result.FirstName = user.FirstName; result.LastName = user.LastName; result.UserId = user.UserID; result.EmailAddress = user.EmailAddress; result.OrganizationName = user.Organization.Name; result.OrganizationURL = _urlHelper.Link("Organizations", new { organizationid = user.Organization.Id }); if (includeContactGroups) result.ContactGroups = user.ContactGroups.Select(c => Create(c,false)); return result; }
public User Parse(UserModel model) { try { var user = new User { FirstName = model.FirstName, LastName = model.LastName, UserID = model.UserId, EmailAddress = model.EmailAddress, OrganizationId = model.OrganizationId, }; //Below code is an example of how to get ID for url's pass in to the model //var uri = new Uri(model.URL); //var notificationId = int.Parse(uri.Segments.Last()); return user; } catch (Exception) { return null; } }