public ActionResult Edit(int id)
        {
            TaxConfigurationVM obj = new TaxConfigurationVM();

            ViewBag.couriermode = db.CourierMovements.ToList();
            ViewBag.parceltypes = db.ParcelTypes.ToList();
            ViewBag.achead      = (from a in db.AcHeads join g in db.AcGroups on a.AcGroupID equals g.AcGroupID join t in db.AcTypes on g.AcTypeId equals t.Id where t.AccountType == "Revenue" select a).ToList();

            var data = (from d in db.TaxConfigurations where d.TaxConfigurationID == id select d).FirstOrDefault();



            if (data == null)
            {
                return(HttpNotFound());
            }
            else
            {
                obj.TaxConfigurationID = data.TaxConfigurationID;
                obj.MoveMentID         = data.CourierMoveMentID;
                obj.ParcelTypeId       = data.ParcelTypeId;
                obj.TaxPercentage      = data.TaxPercentage;
                obj.SaleHeadID         = data.SalesHeadID;
                obj.MinimumRate        = data.MinimumRate.Value;
                obj.AcCompanyID        = data.AcCompanyID.Value;
                obj.EffectFromDate     = data.EffectFromDate.Value;
            }
            return(View(obj));
        }
        public ActionResult Create(TaxConfigurationVM item)
        {
            int companyid = Convert.ToInt32(Session["CurrentCompanyID"].ToString());

            if (ModelState.IsValid)
            {
                TaxConfiguration obj = new TaxConfiguration();

                int max = (from c in db.TaxConfigurations orderby c.TaxConfigurationID descending select c.TaxConfigurationID).FirstOrDefault();

                if (max == null)
                {
                    obj.TaxConfigurationID = 1;
                    obj.CourierMoveMentID  = item.MoveMentID;
                    obj.ParcelTypeId       = item.ParcelTypeId;
                    obj.TaxPercentage      = item.TaxPercentage;
                    obj.SalesHeadID        = item.SaleHeadID;
                    obj.MinimumRate        = item.MinimumRate;
                    obj.AcCompanyID        = companyid;
                    obj.EffectFromDate     = item.EffectFromDate;
                }
                else
                {
                    obj.TaxConfigurationID = max + 1;
                    obj.CourierMoveMentID  = item.MoveMentID;
                    obj.ParcelTypeId       = item.ParcelTypeId;
                    obj.TaxPercentage      = item.TaxPercentage;
                    obj.SalesHeadID        = item.SaleHeadID;
                    obj.MinimumRate        = item.MinimumRate;
                    obj.AcCompanyID        = companyid;
                    obj.EffectFromDate     = item.EffectFromDate;
                }

                db.TaxConfigurations.Add(obj);
                db.SaveChanges();
                TempData["SuccessMsg"] = "You have successfully added TaxConfiguration.";
                return(RedirectToAction("Index"));
            }

            return(View(item));
        }
        public ActionResult Edit(TaxConfigurationVM data)
        {
            int companyid        = Convert.ToInt32(Session["CurrentCompanyID"].ToString());
            TaxConfiguration obj = new TaxConfiguration();

            obj.TaxConfigurationID = data.TaxConfigurationID;
            obj.CourierMoveMentID  = data.MoveMentID;
            obj.ParcelTypeId       = data.ParcelTypeId;
            obj.TaxPercentage      = data.TaxPercentage;
            obj.SalesHeadID        = data.SaleHeadID;
            obj.MinimumRate        = data.MinimumRate;
            obj.AcCompanyID        = companyid;
            obj.EffectFromDate     = data.EffectFromDate;

            if (ModelState.IsValid)
            {
                db.Entry(obj).State = EntityState.Modified;
                db.SaveChanges();
                TempData["SuccessMsg"] = "You have successfully Updated TaxConfiguration.";
                return(RedirectToAction("Index"));
            }
            return(View());
        }