public bool SaveClientEdits(ClientProfileModel clientProfileModel) { ClientProfile existingClient = this.Repository.Single <ClientProfile>(x => x.id_client == (int)clientProfileModel.ClientId); this.Repository.Dispose(); ClientProfile clientProfile = Mapper.Map <ClientProfile>(clientProfileModel); //properties that dont change clientProfile.created_at = existingClient.created_at; clientProfile.id_client = existingClient.id_client; clientProfile.deleted_on = existingClient.deleted_on; clientProfile.client_name = clientProfileModel.ClientName; clientProfile.fk_state = clientProfileModel.StateId; clientProfile.zip_4 = clientProfileModel.Zip4; clientProfile.fk_company_location = clientProfileModel.CompanyLocationId; clientProfile.updated_at = DateTime.Now; clientProfile.FillInNulls(); this.Repository.NewContext(); this.Repository.Modify(clientProfile); this.Repository.CommitAndDispose(); return(true); }
public bool SaveNewClient(ClientProfileModel clientProfileModel) { //build ClientProfile clientProfile = Mapper.Map <ClientProfile>(clientProfileModel); clientProfile.fk_company_location = clientProfileModel.CompanyLocationId; clientProfile.fk_state = clientProfileModel.StateId; clientProfile.created_at = DateTime.Now; clientProfile.updated_at = DateTime.Now; clientProfile.FillInNulls(); //save this.Repository.Add(clientProfile); this.Repository.CommitAndDispose(); return(true); }