public ActionResult Approve(TransferModel model)
        {
            var transfer = _transferRepository.GetById(model.Id);

            Validate(model, transfer, WorkflowActionName.Approve);
            if (ModelState.IsValid)
            {
                transfer = model.ToEntity(transfer);

                if (transfer.IsNew == true)
                {
                    string number = _autoNumberService.GenerateNextAutoNumber(_dateTimeHelper.ConvertToUserTime(DateTime.UtcNow, DateTimeKind.Utc), transfer);
                    transfer.Number = number;
                }

                //always set IsNew to false when saving
                transfer.IsNew = false;
                //update attributes
                _transferRepository.Update(transfer);

                //commit all changes in UI
                this._dbContext.SaveChanges();

                //approve
                _transferService.Approve(transfer);

                //notification
                SuccessNotification(_localizationService.GetResource("Record.Saved"));
                return(Json(new { number = transfer.Number, isApproved = transfer.IsApproved }));
            }
            else
            {
                return(Json(new { Errors = ModelState.SerializeErrors() }));
            }
        }
Example #2
0
        public ActionResult Approve(int id)
        {
            var transfer = _transferService.FindById(id);

            if (transfer != null)
            {
                try
                {
                    if (_transferService.CreateRequisitonForTransfer(transfer))
                    {
                        _transferService.Approve(transfer);
                        return(RedirectToAction("Detail", new { id = transfer.TransferID }));
                    }
                    TempData["CustomError"] = @"Unable to Approve the given Transfer(Free Stock may not be available with this SI number)";
                    return(RedirectToAction("Detail", new { id = transfer.TransferID }));
                }
                catch (Exception exception)
                {
                    var log = new Logger();
                    log.LogAllErrorsMesseges(exception, _log);
                    ModelState.AddModelError("Errors", @"Unable to Approve the given Transfer");
                }
            }
            ModelState.AddModelError("Errors", @"Unable to Approve the given Transfer");
            return(RedirectToAction("Index"));
        }
Example #3
0
        public ActionResult Approve(int id)
        {
            var transfer = _transferService.FindById(id);

            if (transfer != null)
            {
                _transferService.Approve(transfer);
                return(RedirectToAction("Detail", new { id = transfer.TransferID }));
            }
            ModelState.AddModelError("Errors", @"Unable to Approve the given Transfer");
            return(RedirectToAction("Index"));
        }