public void updateOrder(Order order) { HostingUnit unit = getHostingUnitByOrder(order); GuestRequest request = getGuestReqByOrder(order); DateTime EntryDate = request.EntryDate, ReleaseDate = request.ReleaseDate; int length = daysDistance(EntryDate, ReleaseDate); if (order.isClosed) { throw new Exception("ההזמנה נסגרה, לא ניתן לשנות את הסטטוס שלה"); } if (order.Status == OrderStatusEnum.Closes_with_customer_response) { if (!isOrderDateAvailable(order)) { throw new Exception("התאריכים כבר לא זמינים"); } else { order.isClosed = true; dal.AddProfitToAdmin(dal.getFee()); for (int i = 0; i < length; i++) { unit.AllDates.Add(EntryDate); EntryDate = EntryDate.AddDays(1); } dal.updateHostingUnit(unit); GuestRequest guestRequest = getGuestReqByOrder(order); string PrivateName = guestRequest.PrivateName, FamilyName = guestRequest.FamilyName, MailAddress = guestRequest.MailAddress; foreach (var item in dal.getListGuestRequest()) { if (item.FamilyName == FamilyName && item.PrivateName == PrivateName && item.MailAddress == MailAddress) { item.Status = GuestReqStatusEnum.closed; dal.updateGuestReq(item); } } } } if (order.Status == OrderStatusEnum.mail_has_been_sent) { if (getHostingUnitByOrder(order).Owner.CollectionClearance == false) { throw new Exception("לא ניתן לשלוח מייל כל עוד ולא אושרה ההרשאה לחיוב"); } order.OrderDate = DateTime.Now; order.isSendMail = true; } dal.updateOrder(order); }