public override void AddBookVisit(BookVisit bookVisit) { var visit = context.BookVisits.First(x => x.Date.Date == bookVisit.Date.Date); if (visit == null) { context.BookVisits.Add(bookVisit); } else { visit.Quantity += 1; } context.SaveChanges(); }
public void BookAsync(BookVisitViewModel viewModel) { AsyncManager.Parameters["viewModel"] = viewModel; var calendarValidationMessages = _appointmentService.ValidateBook(new ValidateBookRequest { EmployeeId = viewModel.ConsultantId.Value, DepartmentId = Constants.SalesDepartmentId, Start = viewModel.Start, End = viewModel.End }).ToList(); if (calendarValidationMessages.Any()) { calendarValidationMessages.ForEach(message => ModelState.AddModelError("", message.Text)); return; } var bookVisitCommand = new BookVisit { Id = viewModel.Id, AppointmentId = viewModel.AppointmentId, LeadId = viewModel.LeadId, Start = viewModel.Start, End = viewModel.End, ConsultantId = viewModel.ConsultantId }; var bookAppointmentCommand = new BookAppointment { Id = viewModel.AppointmentId, EmployeeId = viewModel.ConsultantId.Value, DepartmentId = Constants.SalesDepartmentId, Start = viewModel.Start, End = viewModel.End, }; _bus.Send(bookVisitCommand).Register <SalesReplies.ReturnCode>(returnCode => AsyncManager.Parameters["salesReturnCode"] = returnCode); _bus.Send(bookAppointmentCommand).Register <CalendarReplies.ReturnCode>(returnCode => AsyncManager.Parameters["calendarReturnCode"] = returnCode); }
public abstract void AddBookVisit(BookVisit bookVisit);