private HourCostEntity InsertEntity(HourCostUpdateDto hourCostDto) { HourCostEntity entity = Mapper.Map <HourCostEntity>(hourCostDto); entity.Id = 0; return(entity); }
private HourCostEntity UpdateEntity(HourCostUpdateDto hourCostDto) { HourCostEntity entity = _hourCostRepository.GetById(hourCostDto.Id.Value); if (entity == null) { throw new ServiceException("Hour Cost does not exist"); } if (entity.IsDeleted) { throw new ServiceException("Hour Cost has been already deleted"); } entity.Start = hourCostDto.Start.Value; entity.End = hourCostDto.End.Value; entity.Cost = hourCostDto.Cost.Value; if (!entity.IsGeneral) { entity.DayType = hourCostDto.DayType.Value; } return(entity); }
private Mock <IRepository <HourCostEntity> > CreateRepo(int id, HourCostEntity entity) { var repo = new Mock <IRepository <HourCostEntity> >(); repo.Setup(x => x.GetById(id)).Returns(entity); repo.Setup(x => x.Save(It.IsAny <HourCostEntity>())); return(repo); }
public HourCostDto SaveHourCost(HourCostUpdateDto hourCostDto) { HourCostEntity entity = hourCostDto.Id <= 0 ? InsertEntity(hourCostDto) : UpdateEntity(hourCostDto); _hourCostRepository.Save(entity); return(Mapper.Map <HourCostDto>(entity)); }
private StudioSchedule EvaluateStudioSchedule() { List <HourCostEntity> hourCosts = _hourCostRepository.GetAll().ToList(); HourCostEntity general = hourCosts.Single(x => x.IsGeneral); var schedule = Mapper.Map <StudioSchedule>(general); schedule.SpecialCosts = hourCosts .Where(x => !x.IsGeneral) .Select(Mapper.Map <StudioSchedule.SpecialCost>) .ToArray(); return(schedule); }
public StudioSchedule GetSchedule() { HourCostEntity general = _hourCostRepository.GetAll().Single(x => x.IsGeneral); return(Mapper.Map <StudioSchedule>(general)); }