public void AddOrder(Order or) { GuestRequest gr = dal.GetGuestRequests().Find(item => item.GuestRequestKey == or.GuestRequestKey); HostingUnit ho = dal.GetHostingUnits().Find(item => item.HostingUnitKey == or.HostingUnitKey); if (gr != null && ho != null) { bool degel = true; for (DateTime i = gr.EntryDate.AddDays(1); i < gr.ReleaseDate; i = i.AddDays(1)) { if (ho.Diary[i.Day, i.Month] != false) { degel = false; } } if (degel == true) { try { dal.AddOrder(or); } catch (Exception ex) { throw new Exception(ex.Message); } or.CreateDate = DateTime.Today; } else { throw new Exception("This hosting unit isn't aviable in this dates period!"); } } else { throw new Exception("The guest request or the hosting unit doesn't exist!"); } }
public void AddOrder(Order o) { try { Host h = dal_bl.SearchHUbyID(o.HostingUnitKey).Owner; if (!AvailabilityCheck(dal_bl.SearchHUbyID(o.HostingUnitKey), dal_bl.searchGRbyID(o.GuestRequestKey))) { throw new InvalidOperationException("unit not available for this request"); } if (!dal_bl.HUexist(o.HostingUnitKey)) { throw new KeyNotFoundException("unit doesnt exist"); } if (!dal_bl.GRexist(o.GuestRequestKey)) { throw new KeyNotFoundException("request doesnt exist"); } dal_bl.AddOrder(o.Clone()); //o.Status = Status.SentEmail; //UpdateOrder(o.Clone()); if (h.CollectionClearance) { o.SentEmail = Configuration.today; SendEmail(o.Clone()); } else { throw new InvalidOperationException("cannot send email without permission to charge"); } } catch (Exception a) { throw a; } }
/// <summary> /// הוספת הזמנה /// </summary> /// <param name="order"></param> public void AddOrder(Order order) { if (dal.IsOrderExist(order)) { throw new ExceptionMessage("ORDER IS ALREADY EXISTS"); } dal.AddOrder(order); }
public uint AddOrder(OrderBO order) { uint resultKey = 0; try { dal.GetPersonById(order.GuestRequest.ClientId); try { dal.GetUnit(order.HostingUnit.Key); try { resultKey = dal.AddOrder(ConvertOrderBOToDO(order)); } catch (DuplicateKeyException ex) { throw ex; } } catch (MissingMemberException ex) { throw new MissingMemberException("Canot add this order because ", ex.ToString()); } } catch (MissingMemberException ex) { throw new MissingMemberException("Canot add this order because ", ex.ToString()); } return(resultKey); }
public void AddOrder(Order order) { BE.GuestRequest req = myDal.GetGuestRequest(order.GuestRequestKey); BE.HostingUnit unit = myDal.GetHostingUnit(order.HostingUnitKey); //checks if the dates are already occupied for (DateTime currentDate = req.EntryDate; currentDate < req.ReleaseDate; currentDate = currentDate.AddDays(1)) { if (unit.Diary[currentDate.Month - 1, currentDate.Day - 1]) { throw new TheUnitIsOccupiedException(); } } //checks if the request is available if (req.Status == GuestRequestStatus.ConnectedToOrder) { throw new StatusException(); } myDal.AddOrder(order.Clone()); }
/// <summary> /// adds a new order to the data /// </summary> /// <param name="order"></param> public void AddOrder(Order order) { try { GuestRequest g = GetGuestRequestByKey(order.GuestRequestKey); //מחזיר את הבקשה לפי הקוד List <HostingUnit> hostingUnits = checkMatch(g); //מחזיר רשימה של כל המתאימים if (hostingUnits.FirstOrDefault() == null) { throw new KeyNotFoundException("They are no available hosting unit for your request"); } foreach (HostingUnit item in hostingUnits) //עבור כל התאמה מוסיף הזמנה { order.HostingUnitKey = item.HostingUnitKey; dal.AddOrder(order); } } catch (Exception e) { throw e; } }
public void AddOrder(Order order) { xml.AddOrder(order); }