public IActionResult StartCleaning(CleaningModel data) { data.StartTime = DateTime.Now; // data.StartTime = DateTime.ParseExact(startTime, "dd/MM/yyyy HH:mm:ss", CultureInfo.InvariantCulture); return(View("Index", data)); }
public CleaningModel CreateCleaningRequest(CleaningModel model) { var existingCleaning = _cleaningRepository.GetByDateTime(model.Date); if (existingCleaning != null) { throw new Exception("Choose another date and time"); } var cleaningOrder = _mapper.Map <CleaningOrder>(model); var reservedCleaning = _cleaningRepository.Create(cleaningOrder); return(_mapper.Map <CleaningModel>(reservedCleaning)); }
public IActionResult EndCleaning(CleaningModel data) { data.EndTime = DateTime.Now; var finishedCleaningModel = new FinishedCleaningModel(); if (data != null) { var totalTime = data.EndTime.Subtract(data.StartTime); finishedCleaningModel.TotalTime = totalTime.Hours + ":" + totalTime.Minutes + ":" + totalTime.Seconds; } finishedCleaningModel.FinishedTasks = data.FinishedTasks; // TODO: Put in database using (var context = new AdminContext()) { var sess = new CleaningSession() { EndTime = data.EndTime, StartTime = data.StartTime }; context.Sessions.AddRange(sess); foreach (var task in data.FinishedTasks) { var id = context.Tasks.Select(t => t).Where(t => t.Name == task).ToList()[0]; context.SessionTasks.AddRange(new SessionTask() { Session = sess, Task = id }); } context.SaveChanges(); } return(View("CleaningDone", finishedCleaningModel)); }
public IActionResult Index() { var data = new CleaningModel(); return(View(data)); }