Exemplo n.º 1
0
        public Result Update()
        {
            Result result = new Result();

            List <PassengerOrdersItinerariesBLL> PassengerOrdersItinerariesBLL = new PassengerOrdersItinerariesBLL().GetPassengerOrdersItinerariesByPassengerOrderID(this.PassengerOrderID);

            // validate i
            if (PassengerOrdersItinerariesBLL == null || PassengerOrdersItinerariesBLL.Count <= 0)
            {
                result            = new Result();
                result.Entity     = null;
                result.EnumType   = typeof(PassengerOrdersValidationEnum);
                result.EnumMember = PassengerOrdersValidationEnum.RejectedBecauseItineraryRequired.ToString();

                return(result);
            }


            List <PassengerOrdersEscortsBLL> PassengerOrdersEscortsBLL = new PassengerOrdersEscortsBLL().GetPassengerOrdersEscortsByPassengerOrderID(this.PassengerOrderID);

            // validate i
            if (DALInstance.PassengerOrdersEscorts != null && DALInstance.PassengerOrdersEscorts.Count > 4)
            {
                result.Entity     = null;
                result.EnumType   = typeof(PassengerOrdersValidationEnum);
                result.EnumMember = PassengerOrdersValidationEnum.RejectedBecauseMaxEscortMemberInOrdersIsFour.ToString();

                return(result);
            }
            //if (IsPassengerOrderAlreadyTook(DALInstance.EmployeeCareerHistoryID, DALInstance.PassengerOrderTypeID.Value))
            //{
            //    result.Entity = null;
            //    result.EnumType = typeof(PassengerOrdersValidationEnum);
            //    result.EnumMember = PassengerOrdersValidationEnum.RejectedBecausePassengerOrderAlreadyTook.ToString();

            //    return result;
            //}

            result = new Result();
            PassengerOrders PassengerOrder = DALInstance;

            PassengerOrder.LastUpdatedBy = this.LoginIdentity.EmployeeCodeID;
            this.PassengerOrderID        = new PassengerOrdersDAL().Update(PassengerOrder);
            if (this.PassengerOrderID != 0)
            {
                result.Entity     = this;
                result.EnumType   = typeof(PassengerOrdersValidationEnum);
                result.EnumMember = PassengerOrdersValidationEnum.Done.ToString();
            }
            return(result);
        }
Exemplo n.º 2
0
        public Result Add(PassengerOrdersItinerariesBLL ItineraryBLL)
        {
            Result result = new Result();

            //// validate location already exists
            PassengerOrdersItineraries Itinerary = new PassengerOrdersItinerariesDAL()
                                                   .GetPassengerOrdersItinerariesByPassengerOrderID(ItineraryBLL.PassengerOrder.PassengerOrderID)
                                                   .Where(e => e.FromCity.ToUpper().Equals(ItineraryBLL.FromCity.ToUpper()) &&
                                                          e.ToCity.ToUpper().Equals(ItineraryBLL.ToCity.ToUpper())).FirstOrDefault();

            if (Itinerary != null)
            {
                result.Entity     = null;
                result.EnumType   = typeof(PassengerOrdersValidationEnum);
                result.EnumMember = PassengerOrdersValidationEnum.RejectedBecausePassengerOrderItineraryCityAlreadyExist.ToString();

                return(result);
            }

            result = new Result();
            PassengerOrdersItineraries Obj = new PassengerOrdersItineraries()
            {
                PassengerOrderID = ItineraryBLL.PassengerOrder.PassengerOrderID,
                FromCity         = ItineraryBLL.FromCity,
                ToCity           = ItineraryBLL.ToCity,
                CreatedDate      = DateTime.Now,
            };

            this.PassengerOrdersItineraryID = new PassengerOrdersItinerariesDAL().Insert(Obj, ItineraryBLL.LoginIdentity.EmployeeCodeID);
            if (this.PassengerOrdersItineraryID != 0)
            {
                result.Entity     = null;
                result.EnumType   = typeof(PassengerOrdersValidationEnum);
                result.EnumMember = PassengerOrdersValidationEnum.Done.ToString();
            }
            return(result);
        }