Example #1
0
        // GET: /ProductContentHeader/Create

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

            vm.IsActive = true;
            return(View("Create", vm));
        }
Example #2
0
        // GET: /ProductContentHeader/Edit/5
        public ActionResult Edit(int id)
        {
            ProductContentHeader s = _ProductContentHeaderService.GetProductContentHeader(id);

            if (s == null)
            {
                return(HttpNotFound());
            }
            return(View("Create", s));
        }
Example #3
0
        // GET: /PurchaseOrderHeader/Delete/5

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

            if (ProductContentHeader == null)
            {
                return(HttpNotFound());
            }
            ReasonViewModel rvm = new ReasonViewModel()
            {
                id = id,
            };

            return(PartialView("_Reason", rvm));
        }
Example #4
0
        public ActionResult HeaderPost(ProductContentHeader svm)
        {
            if (ModelState.IsValid)
            {
                if (svm.ProductContentHeaderId == 0)
                {
                    svm.CreatedDate  = DateTime.Now;
                    svm.ModifiedDate = DateTime.Now;
                    svm.CreatedBy    = User.Identity.Name;
                    svm.ModifiedBy   = User.Identity.Name;
                    _ProductContentHeaderService.Create(svm);

                    try
                    {
                        _unitOfWork.Save();
                    }

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

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

                    return(RedirectToAction("Edit", new { id = svm.ProductContentHeaderId }).Success("Data saved Successfully"));
                }
                else
                {
                    List <LogTypeViewModel> LogList = new List <LogTypeViewModel>();

                    ProductContentHeader temp = _ProductContentHeaderService.Find(svm.ProductContentHeaderId);

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

                    temp.ProductContentName = svm.ProductContentName;
                    temp.IsActive           = svm.IsActive;
                    temp.ModifiedDate       = DateTime.Now;
                    temp.ModifiedBy         = User.Identity.Name;
                    _ProductContentHeaderService.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", svm));
                    }


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

                    return(RedirectToAction("Index").Success("Data saved successfully"));
                }
            }
            return(View("Create", svm));
        }
 public void Update(ProductContentHeader s)
 {
     s.ObjectState = ObjectState.Modified;
     _unitOfWork.Repository <ProductContentHeader>().Update(s);
 }
 public void Delete(ProductContentHeader s)
 {
     _unitOfWork.Repository <ProductContentHeader>().Delete(s);
 }
 public ProductContentHeader Create(ProductContentHeader s)
 {
     s.ObjectState = ObjectState.Added;
     _unitOfWork.Repository <ProductContentHeader>().Insert(s);
     return(s);
 }