// GET: /ProductMaster/Create

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

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

        public ActionResult Edit(int id)
        {
            DrawBackTariffHead pt = _DrawBackTariffHeadService.Find(id);

            if (pt == null)
            {
                return(HttpNotFound());
            }
            return(View("Create", pt));
        }
        public ActionResult Delete(int id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            DrawBackTariffHead DrawBackTariffHead = _DrawBackTariffHeadService.Find(id);

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

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

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

            if (ModelState.IsValid)
            {
                if (vm.DrawBackTariffHeadId <= 0)
                {
                    pt.CreatedDate  = DateTime.Now;
                    pt.ModifiedDate = DateTime.Now;
                    pt.CreatedBy    = User.Identity.Name;
                    pt.ModifiedBy   = User.Identity.Name;
                    pt.ObjectState  = Model.ObjectState.Added;
                    _DrawBackTariffHeadService.Create(pt);

                    ActivityLog log = new ActivityLog()
                    {
                        ActivityType = (int)(ActivityTypeContants.Added),
                        CreatedBy    = User.Identity.Name,
                        CreatedDate  = DateTime.Now,
                        DocId        = pt.DrawBackTariffHeadId,
                        Narration    = "A new DrawaBackTariffHead is created with the Id " + pt.DrawBackTariffHeadId,
                    };

                    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.DrawBackTariff).DocumentTypeId,
                        DocId        = pt.DrawBackTariffHeadId,
                        ActivityType = (int)ActivityTypeContants.Added,
                    }));

                    return(RedirectToAction("Create").Success("Data saved successfully"));
                }
                else
                {
                    List <LogTypeViewModel> LogList = new List <LogTypeViewModel>();

                    DrawBackTariffHead temp = _DrawBackTariffHeadService.Find(pt.DrawBackTariffHeadId);

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

                    temp.DrawBackTariffHeadName = pt.DrawBackTariffHeadName;
                    temp.IsActive     = pt.IsActive;
                    temp.ModifiedDate = DateTime.Now;
                    temp.ModifiedBy   = User.Identity.Name;
                    temp.ObjectState  = Model.ObjectState.Modified;
                    _DrawBackTariffHeadService.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.DrawBackTariff).DocumentTypeId,
                        DocId           = temp.DrawBackTariffHeadId,
                        ActivityType    = (int)ActivityTypeContants.Modified,
                        xEModifications = Modifications,
                    }));

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

            return(View("Create", vm));
        }