Ejemplo n.º 1
0
        public ActionResult Edit(FAgentRateVM v)
        {
            ForwardingAgentRate obj = new ForwardingAgentRate();

            obj.FAgentRateID = v.FAgentRateID;

            obj.FAgentID    = v.FAgentID;
            obj.ZoneChartID = v.ZoneID;

            int countryid = Convert.ToInt32(Session["depotcountry"].ToString());

            obj.CountryID        = countryid;
            obj.CourierServiceID = v.ProductTypeID;
            obj.BaseWeight       = v.BaseWeight;
            obj.BaseRate         = v.BaseRate;
            db.Entry(obj).State  = EntityState.Modified;
            db.SaveChanges();



            var data = (from c in db.ForwardingAgentRateDets where c.FAgentRateID == v.FAgentRateID select c).ToList();

            foreach (var item in data)
            {
                db.ForwardingAgentRateDets.Remove(item);
                db.SaveChanges();
            }
            foreach (var item in v.FAgentRateDetails)
            {
                ForwardingAgentRateDet ob = new ForwardingAgentRateDet();

                ob.FAgentRateID         = v.FAgentRateID;
                ob.AdditionalWeightFrom = item.AddWtFrom;
                ob.AdditionalWeightTo   = item.AddWtTo;
                ob.IncrementalWeight    = item.IncrWt;
                ob.AdditionalRate       = item.AddRate;

                db.ForwardingAgentRateDets.Add(ob);

                db.SaveChanges();
            }

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 2
0
        public ActionResult Create(FAgentRateVM v)
        {
            ForwardingAgentRate FAge = new ForwardingAgentRate();

            int max = (from d in db.ForwardingAgentRates orderby d.FAgentRateID descending select d.FAgentRateID).FirstOrDefault();


            FAge.FAgentRateID = max + 1;
            FAge.FAgentID     = v.FAgentID;
            FAge.ZoneChartID  = v.ZoneID;

            int countryid = Convert.ToInt32(Session["depotcountry"].ToString());

            FAge.CountryID        = countryid;
            FAge.CourierServiceID = v.ProductTypeID;
            FAge.BaseWeight       = v.BaseWeight;
            FAge.BaseRate         = v.BaseRate;

            db.ForwardingAgentRates.Add(FAge);
            db.SaveChanges();



            foreach (var item in v.FAgentRateDetails)
            {
                ForwardingAgentRateDet a = new ForwardingAgentRateDet();

                a.FAgentRateID         = FAge.FAgentRateID;
                a.AdditionalWeightFrom = item.AddWtFrom;
                a.AdditionalWeightTo   = item.AddWtTo;
                a.IncrementalWeight    = item.IncrWt;
                a.AdditionalRate       = item.AddRate;

                db.ForwardingAgentRateDets.Add(a);


                db.SaveChanges();
            }


            return(RedirectToAction("Index"));
        }