public ConsolidatedUserInformationResponseModel CreateConsolidatedUser([FromBody] JObject jmodel) { var Model = new ConsolidatedUserInformationInputModel() { UserAccount = jmodel["user"].ToObject <UserAccountModel>(), UserAddress = jmodel["address"].ToObject <UserAddressModel>(), ContactInfo = jmodel["contactInfo"].ToObject <ContactInfoModel>(), Interests = jmodel["interests"].ToObject <List <InterestModel> >() }; Model.UserAccount = UserAccountService.CreateUserAccount(Model.UserAccount); Model.UserAddress = AddressService.CreateUserAddress(Model.UserAddress); Model.ContactInfo.UserAccountId = Model.UserAccount.Id; Model.ContactInfo.UserAddressId = Model.UserAddress.Id; Model.ContactInfo = ContactInfoService.CreateUserContactInfo(Model.ContactInfo); if (Model.Interests != null) { foreach (var Interest in Model.Interests) { var NewMapping = new InterestUserMapModel { UserAccountId = Model.UserAccount.Id, InterestId = Interest.Id }; InterestService.CreateInterestUserMap(NewMapping); } } Model.Interests = InterestService.GetUserInterests(Model.UserAccount.Id); return(TransformHelpers.UserInputModelToUserResponseModel(Model)); }
public ConsolidatedUserInformationModel UpdateUserInformation([FromBody] JObject jmodel) { var model = new ConsolidatedUserInformationInputModel() { UserAccount = jmodel["user"].ToObject <UserAccountModel>(), UserAddress = jmodel["address"].ToObject <UserAddressModel>(), ContactInfo = jmodel["contactInfo"].ToObject <ContactInfoModel>(), Interests = jmodel["interests"].ToObject <List <InterestModel> >() }; return(new ConsolidatedUserInformationModel { ContactInfoModel = ContactInfoService.UpdateUserContactInfo(model.ContactInfo), UserAccountModel = UserAccountService.UpdateUserAccount(model.UserAccount), UserAddressModel = AddressService.UpdateUserAddress(model.UserAddress) }); }
public static ConsolidatedUserInformationResponseModel UserInputModelToUserResponseModel(ConsolidatedUserInformationInputModel model) { return(new ConsolidatedUserInformationResponseModel() { address = model.UserAddress, contactInfo = model.ContactInfo, interests = model.Interests, user = new UserAccountViewModel() { FirstName = model.UserAccount.FirstName, LastName = model.UserAccount.LastName, UserName = model.UserAccount.UserName, UserTypeId = model.UserAccount.UserTypeId, Id = model.UserAccount.Id, Age = model.UserAccount.Age, PictureUrl = model.UserAccount.PictureUrl } }); }