private void TransferInfo(TimeFrameSubAttributeDto dto, TimeFrameSubAttribute entity) { if(dto.IsNew) { entity.Id = Guid.NewGuid().ToString(); } entity.From = dto.From; entity.To = dto.To; }
private void Update(TimeFrameSubAttributeDto timeFrameSubAttributeDto) { var timeFrameSubAttributeEntity = _personsAttributeEntity.TimeFrameSubAttribute.Where(x => x.Id == timeFrameSubAttributeDto.Id).FirstOrDefault(); if (timeFrameSubAttributeEntity == null) { throw new Exception("User is not authorised to update this time frame sub attribute"); } TransferInfo(timeFrameSubAttributeDto, timeFrameSubAttributeEntity); _dbContext.Entry(timeFrameSubAttributeEntity).State = System.Data.Entity.EntityState.Modified; }
private void Add(TimeFrameSubAttributeDto timeFrameSubAttributeDto) { var timeFrameSubAttributeEntity = new TimeFrameSubAttribute(); TransferInfo(timeFrameSubAttributeDto, timeFrameSubAttributeEntity); _personsAttributeEntity.TimeFrameSubAttribute.Add(timeFrameSubAttributeEntity); //update subAttrbutes ( }