示例#1
0
        public ActionResult Create(TdsCategory vm)
        {
            TdsCategory pt = vm;

            if (ModelState.IsValid)
            {
                pt.CreatedDate  = DateTime.Now;
                pt.ModifiedDate = DateTime.Now;
                pt.CreatedBy    = User.Identity.Name;
                pt.ModifiedBy   = User.Identity.Name;
                pt.ObjectState  = Model.ObjectState.Added;
                _TdsCategoryService.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.TdsCategory).DocumentTypeId,
                    DocId        = pt.TdsCategoryId,
                    ActivityType = (int)ActivityTypeContants.Added,
                }));

                return(RedirectToAction("Create").Success("Data saved successfully"));
            }
            return(View("Create", vm));
        }
示例#2
0
        // GET: /ProductMaster/Edit/5

        public ActionResult Edit(int id)
        {
            TdsCategory pt = _TdsCategoryService.GetTdsCategory(id);

            if (pt == null)
            {
                return(HttpNotFound());
            }
            return(View("Create", pt));
        }
示例#3
0
        public ActionResult Edit(TdsCategory pt)
        {
            List <LogTypeViewModel> LogList = new List <LogTypeViewModel>();

            if (ModelState.IsValid)
            {
                TdsCategory temp = _TdsCategoryService.Find(pt.TdsCategoryId);

                TdsCategory ExRec = Mapper.Map <TdsCategory>(temp);

                temp.TdsCategoryName = pt.TdsCategoryName;
                temp.ModifiedDate    = DateTime.Now;
                temp.ModifiedBy      = User.Identity.Name;
                temp.ObjectState     = Model.ObjectState.Modified;
                _TdsCategoryService.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.TdsCategory).DocumentTypeId,
                    DocId           = temp.TdsCategoryId,
                    ActivityType    = (int)ActivityTypeContants.Modified,
                    xEModifications = Modifications,
                }));

                return(RedirectToAction("Index").Success("Data saved successfully"));
            }
            return(View("Create", pt));
        }
示例#4
0
        // GET: /ProductMaster/Delete/5

        public ActionResult Delete(int id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TdsCategory TdsCategory = _TdsCategoryService.GetTdsCategory(id);

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

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

            return(PartialView("_Reason", vm));
        }
示例#5
0
        // GET: /ProductMaster/Create

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

            return(View("Create", vm));
        }
 public void Update(TdsCategory pt)
 {
     pt.ObjectState = ObjectState.Modified;
     _unitOfWork.Repository <TdsCategory>().Update(pt);
 }
 public void Delete(TdsCategory pt)
 {
     _unitOfWork.Repository <TdsCategory>().Delete(pt);
 }
 public TdsCategory Create(TdsCategory pt)
 {
     pt.ObjectState = ObjectState.Added;
     _unitOfWork.Repository <TdsCategory>().Insert(pt);
     return(pt);
 }
 public TdsCategory Add(TdsCategory pt)
 {
     _unitOfWork.Repository <TdsCategory>().Insert(pt);
     return(pt);
 }