コード例 #1
0
        public ActionResult Edit(int Id, SpecialFaresModel model)
        {
            TravelSession obj = (TravelSession)Session["TravelPortalSessionInfo"];

            model.SpecialFareId = Id;
            model.UpdatedBy     = obj.AppUserId;
            if (model.hdfAirlineName == 0)
            {
                TempData["ErrorMessage"] = "Please, enter proper airline.";
                return(View(model));
            }
            else if (model.hdfFromCityId == 0)
            {
                TempData["ErrorMessage"] = "Please, enter proper city.";
                return(View(model));
            }
            else if (model.hdfToCityId == 0)
            {
                TempData["ErrorMessage"] = "Please, enter proper city.";
                return(View(model));
            }
            else
            {
                try
                {
                    ser.EditSpecialFare(model);
                }
                catch
                {
                    return(View(model));
                }
            }
            return(RedirectToAction("Index"));
        }
コード例 #2
0
        public SpecialFaresModel GetSpecialFaresDetail(int id)
        {
            Air_SpecialFares result = ent.Air_SpecialFares.Where(x => x.SpecialFareId == id).FirstOrDefault();

            if (result != null)
            {
                SpecialFaresModel model = new SpecialFaresModel();

                model.SpecialFareId  = result.SpecialFareId;
                model.FromCityId     = result.FromCityId;
                model.hdfFromCityId  = (int)result.FromCityId;
                model.FromCityName   = result.AirlineCities.CityName;
                model.ToCityId       = result.ToCityId;
                model.hdfToCityId    = (int)result.ToCityId;
                model.ToCityName     = result.AirlineCities1.CityName;
                model.AirlineId      = result.AirlineId;
                model.hdfAirlineName = (int)result.AirlineId;
                model.AirlineName    = result.Airlines.AirlineName;
                model.RegularFare    = result.RegularFare;
                model.SpecialFare    = result.SpecialFare;
                model.EffectiveFrom  = result.EffectiveFrom;
                model.ExpireOn       = result.ExpireOn;

                return(model);
            }
            return(null);
        }
コード例 #3
0
        public List <SpecialFaresModel> GetSpecialFaresList()
        {
            int sno    = 0;
            var result = ent.Air_SpecialFares;
            List <SpecialFaresModel> model = new List <SpecialFaresModel>();

            foreach (var item in result)
            {
                sno++;
                SpecialFaresModel obj = new SpecialFaresModel();
                obj.SNO           = sno;
                obj.SpecialFareId = item.SpecialFareId;
                obj.FromCityId    = item.FromCityId;
                obj.FromCityName  = item.AirlineCities.CityName;
                obj.ToCityId      = item.ToCityId;
                obj.ToCityName    = item.AirlineCities1.CityName;
                obj.AirlineId     = item.AirlineId;
                obj.AirlineName   = item.Airlines.AirlineName;
                obj.RegularFare   = item.RegularFare;
                obj.SpecialFare   = item.SpecialFare;
                obj.EffectiveFrom = item.EffectiveFrom;
                obj.ExpireOn      = item.ExpireOn;

                model.Add(obj);
            }
            return(model.ToList());
        }
コード例 #4
0
        public ActionResult Edit(int Id)
        {
            SpecialFaresModel model = new SpecialFaresModel();

            model.SpecialFareId = Id;
            model = ser.GetSpecialFaresDetail(Id);

            return(View(model));
        }
コード例 #5
0
        public ActionResult Index(int?page)
        {
            int currentPageIndex    = page.HasValue ? page.Value : 1;
            int defaultPageSize     = 30;
            SpecialFaresModel model = new SpecialFaresModel();

            model.ListSpecialFares = ser.GetSpecialFaresList().ToPagedList(currentPageIndex, defaultPageSize);
            return(View(model));
        }
コード例 #6
0
        public void CreateSpecialFares(SpecialFaresModel model)
        {
            Air_SpecialFares obj = new Air_SpecialFares();

            obj.FromCityId    = model.hdfFromCityId;
            obj.ToCityId      = model.hdfToCityId;
            obj.AirlineId     = model.hdfAirlineName;
            obj.RegularFare   = Convert.ToDouble(model.RegularFare);
            obj.SpecialFare   = Convert.ToDouble(model.SpecialFare);
            obj.CreatedBy     = model.CreatedBy;
            obj.CreatedDate   = DateTime.Now;
            obj.EffectiveFrom = Convert.ToDateTime(model.EffectiveFrom);
            obj.ExpireOn      = Convert.ToDateTime(model.ExpireOn);

            ent.AddToAir_SpecialFares(obj);
            ent.SaveChanges();
        }
コード例 #7
0
        public void EditSpecialFare(SpecialFaresModel model)
        {
            Air_SpecialFares result = ent.Air_SpecialFares.Where(u => u.SpecialFareId == model.SpecialFareId).FirstOrDefault();

            if (result != null)
            {
                result.FromCityId    = model.hdfFromCityId;
                result.ToCityId      = model.hdfToCityId;
                result.AirlineId     = model.hdfAirlineName;
                result.RegularFare   = Convert.ToDouble(model.RegularFare);
                result.SpecialFare   = Convert.ToDouble(model.SpecialFare);
                result.UpdatedBy     = model.UpdatedBy;
                result.UpdatedDate   = DateTime.Now;
                result.EffectiveFrom = Convert.ToDateTime(model.EffectiveFrom);
                result.ExpireOn      = Convert.ToDateTime(model.ExpireOn);

                ent.ApplyCurrentValues(result.EntityKey.EntitySetName, result);
                ent.SaveChanges();
            }
        }
コード例 #8
0
        public ActionResult Create()
        {
            SpecialFaresModel model = new SpecialFaresModel();

            return(View(model));
        }