Exemplo n.º 1
0
        public async Task <ActionResult> CreatePackagingType(AddPackagingTypeViewModel request)
        {
            if (!ModelState.IsValid)
            {
                Alert($"Invalid Request.", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                return(RedirectToAction(nameof(PackagingTypes), new { id = request.PackagingId }));
            }
            try
            {
                var addpackagingTypeRequest = new AddPackagingTypeRequest {
                    PackagingId = request.PackagingId, Name = request.Name, Description = request.Description
                };
                var result = await _packagingTypeService.Create(addpackagingTypeRequest);

                if (!result.Success)
                {
                    Alert($"{result.Message}", NotificationType.info, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                    return(RedirectToAction(nameof(PackagingTypes), new { id = request.PackagingId }));
                }
                Alert($"Packaging Type Created Successfully", NotificationType.success, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                return(RedirectToAction(nameof(PackagingTypes), new { id = request.PackagingId }));
            }
            catch (Exception ex)
            {
                Alert($"Error! {ex.Message}.", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                return(RedirectToAction(nameof(PackagingTypes), new { id = request.PackagingId }));
            }
        }
Exemplo n.º 2
0
        public ActionResult CreatePackagingType(Guid packagingId, string PackagingName)
        {
            var packagingType = new AddPackagingTypeViewModel {
                PackagingId = packagingId
            };

            ViewBag.PackagingName = PackagingName;
            return(View(packagingType));
        }