public void AddOrder(Order newOrder) { try { HostingUnit ExistsUnit = Converters.Conv_DO_To_BO(dal.GetHostingUnit(newOrder.HostingUnitKey)); Host ExistsHost = Converters.Conv_DO_To_BO(dal.GetHost(newOrder.HostId)); if (ExistsUnit == null || ExistsHost == null) { throw new Exception("The unit or the host dosent exsist"); } } catch (Exception e) { throw e; } try { GuestRequest request = GetRequest(newOrder.GuestRequestKey); HostingUnit unit = GetHoustingUinit(newOrder.HostingUnitKey); bool valid = CheckingAvailability(unit, request); if (!valid) { throw new Exception("The dates you requested are not available "); } dal.AddOrder(Converters.Conv_BO_To_DO(newOrder)); } catch (Exception e) { throw e; } }
public IEnumerable <IGrouping <Areas, HostingUnit> > GetGroupHostingUnitsByArea() { return(from hostingUnit in dal.GetHostingUnits(x => x is DO.HostingUnit) let hostingUnitBo = Converters.Conv_DO_To_BO(hostingUnit) group hostingUnitBo by hostingUnitBo.Area into allGropsHostingUnit select allGropsHostingUnit); }
public IEnumerable <IGrouping <int, Host> > GetGroupHostByNumOfHostingUnits() { return(from host in dal.GetHostList() let hostBo = Converters.Conv_DO_To_BO(host) group hostBo by hostBo.MyUnits.Count() into allGropsHost select allGropsHost); }
public IEnumerable <IGrouping <int, GuestRequest> > GetGroupGuestRequestsByNumOfVacationers() { return(from guestR in dal.GetGuestRequests() let guestBo = Converters.Conv_DO_To_BO(guestR) group guestBo by guestBo.Adults + guestBo.Children into allGropsGuestRequests select allGropsGuestRequests); }
public IEnumerable <IGrouping <Areas, GuestRequest> > GetGroupGuestRequestsByArea() { return(from guestR in dal.GetGuestRequests() let guestBo = Converters.Conv_DO_To_BO(guestR) group guestBo by guestBo.Area into allGropsGuestRequests select allGropsGuestRequests); }
public Order GetOrder(int key) { try { return(Converters.Conv_DO_To_BO(dal.GetOrder(key))); } catch (Exception e) { throw e; } }
public Host GetHost(int id) { try { return(Converters.Conv_DO_To_BO(dal.GetHost(id))); } catch (Exception e) { throw e; } }
public IEnumerable <HostingUnit> GetHostingUnitsByHostId(int id) { try { var units = dal.GetHostingUnits(x => x.HostId == id).Select(x => Converters.Conv_DO_To_BO(x)); return(units); } catch (Exception e) { throw e; } }
public HostingUnit GetHoustingUinit(int key) { try { DO.HostingUnit tmp = dal.GetHostingUnit(key); return(Converters.Conv_DO_To_BO(tmp)); } catch (Exception e) { throw e; } }
public IEnumerable <Order> GetOrdersList() { try { var orders = dal.GetOrders(x => x is DO.Order).Select(x => Converters.Conv_DO_To_BO(x)); return(orders); } catch (Exception e) { throw e; } }
public void UpdateStatusOrder(BO.OrderStatus updateorder, int key) { try { BO.Order tmp1 = Converters.Conv_DO_To_BO(dal.GetOrder(key)); if (tmp1.Status == OrderStatus.IGNORED_CLOSED || tmp1.Status == OrderStatus.APPROVED) { throw new Exception("אין אפשרות לשנות את הסטטוס לאחר סגירת עסקה"); } BO.Host temp2 = Converters.Conv_DO_To_BO(dal.GetHost(tmp1.HostId)); if (updateorder == OrderStatus.MAIL_SENT) { if (!temp2.CollectionClearance) { throw new Exception("אין אפשרות לשלוח מייל ללקוח מבלי לחתום על הרשאה לחיוב חשבון"); } } if (updateorder == OrderStatus.APPROVED) { BO.Order update = Converters.Conv_DO_To_BO(dal.GetOrder(key)); BO.HostingUnit unit = Converters.Conv_DO_To_BO(dal.GetHostingUnit(update.HostingUnitKey)); BO.GuestRequest request = Converters.Conv_DO_To_BO(dal.GetGuestRequest(update.GuestRequestKey)); SetDairy(unit, request); dal.UpdateHostingUnit(Converters.Conv_BO_To_DO(unit)); update.ClientName = dal.GetPerson(update.ClientId).FirstName + dal.GetPerson(update.ClientId).LastName; update.Commission = 10; //סכום העמלה dal.UpdateOrder(Converters.Conv_BO_To_DO(update)); List <Order> lst = GetOrdersByRequestKey(request.Key).ToList(); foreach (var i in lst)//change all orders to Irrelevant { if (i.Key != update.Key) { dal.UpdateStatusOrder(i.Key, DO.OrderStatus.IRRELEVANT); } } try { SendEmail(tmp1); } catch (Exception) { throw new Exception("Check your Internet connection"); } //////////////////////////////////////////////////////////////////////////////////////// } dal.UpdateStatusOrder(key, (DO.OrderStatus)updateorder); } catch (Exception e) { throw e; } }
public IEnumerable <GuestRequest> GetGuestRequestByPredicate(Func <GuestRequest, bool> func) { try { var requests = dal.GetGuestRequests(x => func(Converters.Conv_DO_To_BO(x))) .Select(x => Converters.Conv_DO_To_BO(x)); return(requests); } catch (Exception e) { throw e; } }
public void UpdateRequestStatus(BO.RequestStatus status, int key) { GuestRequest Request = Converters.Conv_DO_To_BO(dal.GetGuestRequest(key)); if (Request != null && Request.Status != RequestStatus.OPEN) { throw new Exception("the update is not succeded - olrady sended offers"); } try { dal.UpdateRequestStatus(key, (DO.RequestStatus)status); } catch (Exception e) { throw e; } }
/// <summary> /// the func return all the orders that they have the same hostingunit key /// </summary> /// <param name="key"></param> /// <returns></returns> public IEnumerable <BO.Order> GetOrdersByUnits(int key) { try { var orders = dal.GetOrders(x => x.HostingUnitKey == key).Select(x => Converters.Conv_DO_To_BO(x)); return(orders); } catch (Exception e) { throw e; } //List<BO.Order> tmp = new List<BO.Order>(); //foreach(var i in dal.GetOrders(i=>i.HostId== id)) //{ // tmp.Add(Converters.ConverFrom_DO_To_BoOrder(i)); //} //return tmp; }
public GuestRequest GetRequest(int key) { return(Converters.Conv_DO_To_BO(dal.GetGuestRequest(key))); }
public IEnumerable <Person> GetPersons() { return(dal.GetPersons(). Where(x => x is DO.Person). Select(x => Converters.Conv_DO_To_BO(x)).ToList()); }
public IEnumerable <Host> GetHostList() { return(dal.GetHostList(). Where(x => x is DO.Host). Select(x => Converters.Conv_DO_To_BO(x)).ToList()); }
public IEnumerable <HostingUnit> GetAllHostingUnits() { try { var units = dal.GetHostingUnits(x => x is DO.HostingUnit).Select(x => Converters.Conv_DO_To_BO(x)); return(units); } catch (Exception e) { throw e; } }
/// <summary> /// the func return list of orders by the guest request key /// </summary> /// <param name="key"></param> /// <returns></returns> public IEnumerable <Order> GetOrdersByRequestKey(int key) { try { var orders = dal.GetOrders(x => x.GuestRequestKey == key).Select(x => Converters.Conv_DO_To_BO(x)); return(orders); } catch (Exception e) { throw e; } }
public IEnumerable <GuestRequest> GetGuestRequests(int id) { try { var requests = dal.GetGuestRequests(x => x.ClientId == id).Select(x => Converters.Conv_DO_To_BO(x)); return(requests); } catch (Exception e) { throw e; } }
public Person GetPerson(int id) { return(Converters.Conv_DO_To_BO(dal.GetPerson(id))); }
/// <summary> /// the func return all the orders that they have the same host /// </summary> /// <param name="id"></param> /// <returns></returns> public IEnumerable <BO.Order> GetOrdersByHost(int id) { try { List <Order> ordersListTemp = dal.GetOrders(x => x.HostId == id).Select(x => Converters.Conv_DO_To_BO(x)).ToList(); return(ordersListTemp); } catch (Exception e) { throw e; } }
/// <summary> /// the funk return all guest request /// </summary> /// <returns></returns> public IEnumerable <GuestRequest> GetGuestRequests() { var requests = dal.GetGuestRequests().Select(x => Converters.Conv_DO_To_BO(x)); return(requests); }