// GET: /ProductMaster/Create

        public ActionResult Create()
        {
            ProductRateGroup vm = new ProductRateGroup();

            vm.IsActive = true;
            return(View("Create", vm));
        }
        // GET: /ProductMaster/Edit/5

        public ActionResult Edit(int id)
        {
            ProductRateGroup pt = _ProductRateGroupService.Find(id);

            if (pt == null)
            {
                return(HttpNotFound());
            }
            return(View("Create", pt));
        }
        // GET: /ProductMaster/Delete/5

        public ActionResult Delete(int id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ProductRateGroup ProductRateGroup = _ProductRateGroupService.Find(id);

            if (ProductRateGroup == null)
            {
                return(HttpNotFound());
            }

            ReasonViewModel vm = new ReasonViewModel()
            {
                id = id,
            };

            return(PartialView("_Reason", vm));
        }
Ejemplo n.º 4
0
 public ProductRateGroup Add(ProductRateGroup pt)
 {
     _unitOfWork.Repository <ProductRateGroup>().Insert(pt);
     return(pt);
 }
Ejemplo n.º 5
0
 public void Update(ProductRateGroup pt)
 {
     pt.ObjectState = ObjectState.Modified;
     _unitOfWork.Repository <ProductRateGroup>().Update(pt);
 }
Ejemplo n.º 6
0
 public void Delete(ProductRateGroup pt)
 {
     _unitOfWork.Repository <ProductRateGroup>().Delete(pt);
 }
Ejemplo n.º 7
0
 public ProductRateGroup Create(ProductRateGroup pt)
 {
     pt.ObjectState = ObjectState.Added;
     _unitOfWork.Repository <ProductRateGroup>().Insert(pt);
     return(pt);
 }
        public ActionResult Post(ProductRateGroup vm)
        {
            ProductRateGroup pt = vm;


            if (ModelState.IsValid)
            {
                if (vm.ProductRateGroupId <= 0)
                {
                    int SiteId     = (int)System.Web.HttpContext.Current.Session["SiteId"];
                    int DivisionId = (int)System.Web.HttpContext.Current.Session["DivisionId"];

                    pt.SiteId       = SiteId;
                    pt.DivisionId   = DivisionId;
                    pt.CreatedDate  = DateTime.Now;
                    pt.ModifiedDate = DateTime.Now;
                    pt.CreatedBy    = User.Identity.Name;
                    pt.ModifiedBy   = User.Identity.Name;
                    pt.ObjectState  = Model.ObjectState.Added;
                    _ProductRateGroupService.Create(pt);

                    try
                    {
                        _unitOfWork.Save();
                    }

                    catch (Exception ex)
                    {
                        string message = _exception.HandleException(ex);
                        ModelState.AddModelError("", message);
                        return(View("Create", vm));
                    }

                    LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel
                    {
                        DocTypeId    = new DocumentTypeService(_unitOfWork).FindByName(MasterDocTypeConstants.ProductRateGroup).DocumentTypeId,
                        DocId        = pt.ProductRateGroupId,
                        ActivityType = (int)ActivityTypeContants.Added,
                    }));

                    return(RedirectToAction("Create").Success("Data saved successfully"));
                }

                else
                {
                    List <LogTypeViewModel> LogList = new List <LogTypeViewModel>();
                    ProductRateGroup        temp    = _ProductRateGroupService.Find(pt.ProductRateGroupId);

                    ProductRateGroup ExRec = Mapper.Map <ProductRateGroup>(temp);
                    temp.Processes            = pt.Processes;
                    temp.ProductRateGroupName = pt.ProductRateGroupName;
                    temp.IsActive             = pt.IsActive;
                    temp.ModifiedDate         = DateTime.Now;
                    temp.ModifiedBy           = User.Identity.Name;
                    temp.ObjectState          = Model.ObjectState.Modified;
                    _ProductRateGroupService.Update(temp);

                    LogList.Add(new LogTypeViewModel
                    {
                        ExObj = ExRec,
                        Obj   = temp,
                    });
                    XElement Modifications = new ModificationsCheckService().CheckChanges(LogList);

                    try
                    {
                        _unitOfWork.Save();
                    }

                    catch (Exception ex)
                    {
                        string message = _exception.HandleException(ex);
                        ModelState.AddModelError("", message);
                        return(View("Create", pt));
                    }

                    LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel
                    {
                        DocTypeId       = new DocumentTypeService(_unitOfWork).FindByName(MasterDocTypeConstants.ProductRateGroup).DocumentTypeId,
                        DocId           = temp.ProductRateGroupId,
                        ActivityType    = (int)ActivityTypeContants.Modified,
                        xEModifications = Modifications,
                    }));

                    return(RedirectToAction("Index").Success("Data saved successfully"));
                }
            }
            return(View("Create", vm));
        }