Exemplo n.º 1
0
        public async Task <ActionResult> CreateUOM(AddUOMViewModel request)
        {
            if (!ModelState.IsValid)
            {
                Alert($"Invalid Request.", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                return(RedirectToAction(nameof(UnitOfMeasures), new { id = request.UomTypeId }));
            }
            try
            {
                var addUOMRequest = new AddUnitOfMeasureRequest {
                    UnitOfMeasureTypeId = request.UomTypeId, Name = request.Name, Description = request.Description, Grammage = request.Grammage, PackSize = request.PackSize, PalletSize = request.PalletSize
                };
                var result = await _unitOfMeasureService.Create(addUOMRequest);

                if (!result.Success)
                {
                    Alert($"{result.Message}", NotificationType.info, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                    return(RedirectToAction(nameof(UnitOfMeasures), new { id = request.UomTypeId }));
                }
                Alert($"Unit Of Measure Created Successfully", NotificationType.success, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                return(RedirectToAction(nameof(UnitOfMeasures), new { id = request.UomTypeId }));
            }
            catch (Exception ex)
            {
                Alert($"Error! {ex.Message}.", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                return(RedirectToAction(nameof(UnitOfMeasures), new { id = request.UomTypeId }));
            }
        }
Exemplo n.º 2
0
        // GET: UnitOfMeasureType/CreateUOM
        public ActionResult CreateUOM(Guid uomTypeId, string UomTypeName)
        {
            var uomVm = new AddUOMViewModel {
                UomTypeId = uomTypeId
            };

            ViewBag.UomTypeName = UomTypeName;
            return(View(uomVm));
        }