Пример #1
0
        public void Update(DARViewModel vmDAR, string UserName)
        {
            DAR objDAR = Find(vmDAR.DARId);

            objDAR.DARDate     = vmDAR.DARDate;
            objDAR.Description = vmDAR.Description;
            objDAR.DueDate     = vmDAR.DueDate;
            objDAR.ForUser     = vmDAR.ForUser;
            objDAR.FromTime    = vmDAR.FromTime;
            objDAR.IsActive    = vmDAR.IsActive;
            objDAR.Priority    = vmDAR.Priority;
            objDAR.Status      = vmDAR.Status;
            objDAR.TaskId      = vmDAR.TaskId;
            objDAR.ToTime      = vmDAR.ToTime;
            objDAR.WorkHours   = vmDAR.WorkHours;

            objDAR.ModifiedDate = DateTime.Now;
            objDAR.ModifiedBy   = UserName;
            objDAR.ObjectState  = ObjectState.Modified;
            _DARRepository.Update(objDAR);


            if (objDAR.TaskId != 0)
            {
                Tasks objTAsks = _TaskRepository.Find(vmDAR.TaskId);
                objTAsks.Status       = vmDAR.Status;
                objTAsks.ModifiedDate = DateTime.Now;
                objTAsks.ModifiedBy   = UserName;
                _TaskRepository.Update(objTAsks);
            }
            _uniOfWork.Save();
        }
Пример #2
0
        public DARViewModel Create(DARViewModel vmDAR, string UserName)
        {
            DAR objDAR = new DAR();

            objDAR = Mapper.Map <DAR>(vmDAR);

            objDAR.CreatedBy    = UserName;
            objDAR.CreatedDate  = DateTime.Now;
            objDAR.ModifiedBy   = UserName;
            objDAR.ModifiedDate = DateTime.Now;
            objDAR.ObjectState  = ObjectState.Added;

            _DARRepository.Add(objDAR);

            if (objDAR.TaskId != 0)
            {
                Tasks objTasks = _TaskRepository.Find(objDAR.TaskId);
                objTasks.Status       = objDAR.Status;
                objTasks.ModifiedBy   = UserName;
                objTasks.ModifiedDate = DateTime.Now;
                _TaskRepository.Update(objTasks);
            }

            _uniOfWork.Save();

            vmDAR.DARId = objDAR.DARId;

            return(vmDAR);
        }
Пример #3
0
        // GET: /ProductMaster/Edit/5

        public ActionResult Edit(int id)
        {
            DARViewModel vmDAR = _DarService.FindViewModel(id);

            if (vmDAR == null)
            {
                return(HttpNotFound());
            }
            PrepareViewBag();
            return(View("Create", vmDAR));
        }
Пример #4
0
        // GET: /DARMaster/Create

        public ActionResult Create(int?id)
        {
            DARViewModel vmDAR = new DARViewModel();

            vmDAR.IsActive = true;
            vmDAR.DARDate  = DateTime.Now;
            if (id.HasValue && id.Value > 0)
            {
                vmDAR.TaskId = id.Value;
                vmDAR.Status = _TaskService.Find(vmDAR.TaskId).Status;
            }
            PrepareViewBag();
            vmDAR.ForUser = (string.IsNullOrEmpty(DARUser) ? User.Identity.Name : DARUser);
            return(View("Create", vmDAR));
        }
Пример #5
0
        public ActionResult Post(DARViewModel vmDAR)
        {
            if (vmDAR.WorkHours <= 0)
            {
                ModelState.AddModelError("WorkHours", "Work hours field is required");
            }

            if (ModelState.IsValid)
            {
                if (vmDAR.DARId <= 0)
                {
                    try
                    {
                        _DarService.Create(vmDAR, (string.IsNullOrEmpty(DARUser) ? User.Identity.Name : DARUser));
                    }

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

                    return(RedirectToAction("Create").Success("Data saved successfully"));
                }
                else
                {
                    try
                    {
                        _DarService.Update(vmDAR, (string.IsNullOrEmpty(DARUser) ? User.Identity.Name : DARUser));
                    }

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


                    return(RedirectToAction("Index").Success("Data saved successfully"));
                }
            }
            PrepareViewBag();
            return(View("Create", vmDAR));
        }
Пример #6
0
        // GET: /ProductMaster/Delete/5

        public ActionResult Delete(int id)
        {
            if (id == 0)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            DARViewModel vmDAR = _DarService.FindViewModel(id);

            if (vmDAR == null)
            {
                return(HttpNotFound());
            }
            ReasonViewModel vm = new ReasonViewModel()
            {
                id = id,
            };

            return(PartialView("_Reason", vm));
        }