public ActionResult Edit(Guid id) { var model = new HospitalBookProcessViewModel(); using (UnitOfWorkManager.NewUnitOfWork()) { CompanySubOrder order = _companySubOrderService.GetById(id); model.CompanySubOrder = order; } return(View(model)); }
public string CreateNewSubOrder(DateTime date, string comment) { var returnObject = new AJAXReturnObject(); try { using (var unitOfWork = UnitOfWorkManager.NewUnitOfWork()) { IList <CompanySubOrder> orders = _companySubOrderService.GetByDate(date, date.AddDays(1)); if (orders.Count > 0) { returnObject.Status = AJAXReturnResult.Failed; returnObject.Message = "您预定的日期已被其他企业预定。"; } else { Category initStatus = _categoryService.GetById(17); var company = _companyService.GetById(WorkContext.CurrentMembershipUser.Company.Id); CompanySubOrder order = new CompanySubOrder { StartDate = date, EndDate = date.AddDays(1), BookStatus = initStatus, Comment = comment, Company = company, CreatedBy = WorkContext.CurrentMembershipUser.Username, ParentOrder = null }; _companySubOrderService.Add(order); try { unitOfWork.Commit(); } catch (Exception ex) { unitOfWork.Rollback(); throw ex; } } } } catch (Exception ex) { returnObject.Status = AJAXReturnResult.Failed; returnObject.Message = ex.Message; } return(JsonHelper.SerializeToJson(returnObject)); }
public void Add(CompanySubOrder order) { //IList<HospitalCalendar> calendars = _hospitalCalendarRepository.GetCalendarData(Convert.ToDateTime(order.StartDate), Convert.ToDateTime(order.EndDate)); //if (calendars.Count == 0) //{ // HospitalCalendar entity = new HospitalCalendar // { // StartDate = order.StartDate, // EndDate = order.EndDate, // CreatedBy = order.CreatedBy // }; // _hospitalCalendarRepository.AddCalendar(entity); //} _companySubOrderRepository.Add(order); }
public void ApproveSubOrder(Guid subOrderId, DateTime date, bool approved) { DateTime? oldStartTime = null; CompanySubOrder subOrder = GetById(subOrderId); oldStartTime = subOrder.StartDate; var bookStatus = _categoryService.GetById(18); if (!approved) { bookStatus = _categoryService.GetById(19); } subOrder.StartDate = date; subOrder.EndDate = date.AddDays(1); subOrder.UpdatedBy = _workContext.CurrentMembershipUser.Username; subOrder.UpdatedDate = DateTime.Now; subOrder.BookStatus = bookStatus; //if (subOrder.Company.MembershipUser.EmailTaskTypes.FirstOrDefault(x => x.Id == 28) != null) //{ // string emailBody = string.Empty; // if (approved) // { // if (oldStartTime == date) // { // emailBody = string.Format(APPROVE_EMAIL_BY_HOSPITAL_FORMATTER, Convert.ToDateTime(date).ToString("yyyy-MM-dd")); // } // else // { // emailBody = string.Format(APPROVE_CHANGE_EMAIL_BY_HOSPITAL_FORMATTER, Convert.ToDateTime(oldStartTime).ToString("yyyy-MM-dd"), Convert.ToDateTime(date).ToString("yyyy-MM-dd")); // } // } // else // { // emailBody = string.Format(REJECT_EMAIL_BY_HOSPITAL_FORMATTER, Convert.ToDateTime(oldStartTime).ToString("yyyy-MM-dd")); // } // var email = new Email // { // To = subOrder.Company.MembershipUser.Email, // ToName = subOrder.Company.CompanyName, // Body = string.Format(EmailBodyFormatter.EnterpriseBody, subOrder.Company.CompanyName, emailBody), // }; // _emailService.Add(email); //} }
public void Delete(CompanySubOrder entity) { _context.CompanySubOrder.Remove(entity); }
public void Add(CompanySubOrder order) { _context.CompanySubOrder.Add(order); }