示例#1
0
        public ActionResult Edit(int id = 0)
        {
            AgentDeliveryRateVM a = new AgentDeliveryRateVM();

            ViewBag.producttypeid = db.ProductTypes.ToList();
            ViewBag.agent         = (from c in db.EmployeeMasters where c.Type == "A" select c).ToList();
            ViewBag.ZoneID        = db.ZoneCharts.ToList();

            tblAgentDeliveryRate data = (from c in db.tblAgentDeliveryRates where c.ID == id select c).FirstOrDefault();

            if (data == null)
            {
                return(HttpNotFound());
            }
            else
            {
                a.ID          = data.ID;
                a.AgentID     = data.AgentID;
                a.ZoneChartID = data.ZoneChartID;

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

                a.ProductTypeID = data.CourierServiceID;
                a.BaseWeight    = data.BaseWeight;
                a.BaseRate      = data.BaseRate;
            }



            return(View(a));
        }
示例#2
0
        public ActionResult Edit(AgentDeliveryRateVM v)
        {
            tblAgentDeliveryRate a = new tblAgentDeliveryRate();

            a.ID          = v.ID;
            a.AgentID     = v.AgentID;
            a.ZoneChartID = v.ZoneID;

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

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

            db.Entry(a).State = EntityState.Modified;
            db.SaveChanges();

            var data = (from c in db.tblAgentDeliveryRateDetails where c.AgentDeliveryRateID == v.ID select c).ToList();

            foreach (var item in data)
            {
                db.tblAgentDeliveryRateDetails.Remove(item);
                db.SaveChanges();
            }
            foreach (var item in v.AgentDeliveryRateDetailVM)
            {
                tblAgentDeliveryRateDetail b = new tblAgentDeliveryRateDetail();

                b.AgentDeliveryRateID  = a.ID;
                b.AdditionalWeightFrom = item.AddWtFrom;
                b.AdditionalWeightTo   = item.AddWtTo;
                b.IncrementalWeight    = item.IncrWt;
                b.AdditionalRate       = item.AddRate;

                db.tblAgentDeliveryRateDetails.Add(b);


                db.SaveChanges();
            }


            return(RedirectToAction("Index"));
        }
示例#3
0
        public ActionResult Create(AgentDeliveryRateVM v)
        {
            tblAgentDeliveryRate a = new tblAgentDeliveryRate();
            int max = (from d in db.tblAgentDeliveryRates orderby d.ID descending select d.ID).FirstOrDefault();

            a.ID          = max + 1;
            a.AgentID     = v.AgentID;
            a.ZoneChartID = v.ZoneID;

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

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

            db.tblAgentDeliveryRates.Add(a);
            db.SaveChanges();


            foreach (var item in v.AgentDeliveryRateDetailVM)
            {
                tblAgentDeliveryRateDetail b = new tblAgentDeliveryRateDetail();

                b.AgentDeliveryRateID  = a.ID;
                b.AdditionalWeightFrom = item.AddWtFrom;
                b.AdditionalWeightTo   = item.AddWtTo;
                b.IncrementalWeight    = item.IncrWt;
                b.AdditionalRate       = item.AddRate;

                db.tblAgentDeliveryRateDetails.Add(b);


                db.SaveChanges();
            }

            return(RedirectToAction("Index"));
        }