private void Update(PersonsAttributeDto personsAttributeDto) { var personsAttributeEntity = _personEntity.PersonsAttribute.Where(x => x.Id == personsAttributeDto.Id).FirstOrDefault(); if (personsAttributeEntity == null) { throw new Exception("User is not authorised to update this persons attribute"); } TranferInfo(personsAttributeDto, personsAttributeEntity); _dbContext.Entry(personsAttributeEntity).State = System.Data.Entity.EntityState.Modified; //update subAttrbutes ( var personalSubAttribute = new UpdatePersonalSubAttribute(_dbContext, personsAttributeEntity, personsAttributeDto.PersonalSubAttributeDtos.ToList(), _applicationUserId); personalSubAttribute.PerformAction(); var addressSubAttribute = new UpdateAddressSubAttribute(_dbContext, personsAttributeEntity, personsAttributeDto.AddressSubAttributeDtos.ToList(), _applicationUserId); addressSubAttribute.PerformAction(); var phoneNumberSubAttribute = new UpdatePhoneNumberSubAttribute(_dbContext, personsAttributeEntity, personsAttributeDto.PhoneNumberSubAttributeDtos.ToList(), _applicationUserId); phoneNumberSubAttribute.PerformAction(); var updateTimeFrameSubAttribute = new UpdateTimeFrameSubAttribute(_dbContext, personsAttributeEntity, personsAttributeDto.TimeFrameSubAttributeDtos.ToList(), _applicationUserId); updateTimeFrameSubAttribute.PerformAction(); }
private void Add(PersonsAttributeDto personsAttributeDto) { var personsAttributeEntity = new PersonsAttribute(); TranferInfo(personsAttributeDto, personsAttributeEntity); _personEntity.PersonsAttribute.Add(personsAttributeEntity); //update subAttrbutes ( var personalSubAttribute = new UpdatePersonalSubAttribute(_dbContext, personsAttributeEntity, personsAttributeDto.PersonalSubAttributeDtos.ToList() , _applicationUserId); personalSubAttribute.PerformAction(); var addressSubAttribute = new UpdateAddressSubAttribute(_dbContext, personsAttributeEntity, personsAttributeDto.AddressSubAttributeDtos.ToList(), _applicationUserId); addressSubAttribute.PerformAction(); var phoneNumberSubAttribute = new UpdatePhoneNumberSubAttribute(_dbContext, personsAttributeEntity, personsAttributeDto.PhoneNumberSubAttributeDtos.ToList(), _applicationUserId); phoneNumberSubAttribute.PerformAction(); var updateTimeFrameSubAttribute = new UpdateTimeFrameSubAttribute(_dbContext, personsAttributeEntity, personsAttributeDto.TimeFrameSubAttributeDtos.ToList(), _applicationUserId); updateTimeFrameSubAttribute.PerformAction(); }