public void Schedule_basic_renovation_return_null() { RenovationService renovationService = SetupRenovationService(); BaseRenovation result = renovationService.AddBaseRenovation(_createRenovaton.CreateInvalidTestObjectForSchedulingBaseRenovation()); Assert.Null(result); }
public void DeleteRenovation(int id) { BaseRenovation baseRenovation = _context.BaseRenovation.Find(id); if (baseRenovation != null) { _context.BaseRenovation.Remove(baseRenovation); _context.SaveChanges(); } }
public ActionResult AddBaseRenovation(BaseRenovationDTO baseRenovationDTO) { BaseRenovation addedBaseRenovation = _renovationService.AddBaseRenovation(BaseRenovationMapper.BaseRenovationDTOToBaseRenovation(baseRenovationDTO)); if (addedBaseRenovation == null) { return(NotFound("NotFound")); } return(Ok()); }
public static BaseRenovation BaseRenovationDTOToBaseRenovation(BaseRenovationDTO baseRenovationDTO) { BaseRenovation baseRenovation = new BaseRenovation(); baseRenovation.RoomId = baseRenovationDTO.RoomId; baseRenovation.RenovationPeriod = new RenovationPeriod(baseRenovationDTO.StartTime, baseRenovationDTO.EndTime); baseRenovation.Description = baseRenovationDTO.Description; baseRenovation.TypeOfRenovation = baseRenovationDTO.TypeOfRenovation; return(baseRenovation); }
public IActionResult GetBaseRenovationsById(int baseRenovationId) { try { BaseRenovation baseRenovation = _renovationService.GetRenovationById(baseRenovationId); return(Ok(BaseRenovationMapper.BaseRenovationToBaseRenovationDTO(baseRenovation))); } catch (Exception e) { return(NotFound(e.Message)); } }
public static BaseRenovationDTO BaseRenovationToBaseRenovationDTO(BaseRenovation baseRenovation) { BaseRenovationDTO baseRenovationDTO = new BaseRenovationDTO(); baseRenovationDTO.RoomId = baseRenovation.RoomId; baseRenovationDTO.StartTime = baseRenovation.RenovationPeriod.BeginDate; baseRenovationDTO.EndTime = baseRenovation.RenovationPeriod.EndDate; baseRenovation.TypeOfRenovation = baseRenovation.TypeOfRenovation; baseRenovation.Description = baseRenovation.Description; return(baseRenovationDTO); }
public BaseRenovation AddBaseRenovation(BaseRenovation baseRenovation) { if (!CheckIfRoomIsAbsoulitelyAvailable(baseRenovation.RenovationPeriod, baseRenovation.RoomId)) { return(null); } if (baseRenovation.TypeOfRenovation == TypeOfRenovation.MERGE_RENOVATION) { if (!CheckIfRoomIsAbsoulitelyAvailable(baseRenovation.RenovationPeriod, ((MergeRenovation)baseRenovation).SecondRoomId)) { return(null); } } baseRenovation.RenovationPeriod.BeginDate = SetNewDateTimesForRenovation(baseRenovation.RenovationPeriod.BeginDate); baseRenovation.RenovationPeriod.EndDate = SetNewDateTimesForRenovation(baseRenovation.RenovationPeriod.EndDate); return(_renovationRepository.AddRenovation(baseRenovation)); }
private List <RenovationPeriod> GetRenovationAlternativeAppointmets(BaseRenovation renovation, DateTime lastAppointment) { int timeSpanInMinutes = (int)renovation.RenovationPeriod.EndDate.Subtract(renovation.RenovationPeriod.BeginDate).TotalMinutes; DateTime start = lastAppointment.AddMinutes(30); DateTime end = start.AddMinutes(timeSpanInMinutes); List <RenovationPeriod> alternativeAppointments = new List <RenovationPeriod>(); int i = 0; while (i < 10) { if (CheckIfTimeValid(start) && CheckIfTimeValid(end)) { alternativeAppointments.Add(new RenovationPeriod(start, end)); i++; } start = end; end = end.AddMinutes(timeSpanInMinutes); } return(alternativeAppointments); }
public BaseRenovation AddRenovation(BaseRenovation baseRenovation) { _context.BaseRenovation.Add(baseRenovation); _context.SaveChanges(); return(baseRenovation); }
public static RoomSchedulesDTO Renovation_To_RoomSchedulesDTO(BaseRenovation renovation) { return(new RoomSchedulesDTO(renovation.RenovationPeriod.BeginDate, ScheduleType.Renovation, renovation.Id)); }