Пример #1
0
        // GET: Packagings/Details/5
        public async Task <ActionResult> Details(Guid id)
        {
            var packaging = new PackagingDetailsViewModel();

            try
            {
                var result = await _packagingService.FindById(id);

                if (!result.Success)
                {
                    Alert($"Error! {result.Message}", NotificationType.info, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                    return(View(packaging));
                }
                packaging.Code            = result.Data.Code;
                packaging.Id              = result.Data.Id;
                packaging.Name            = result.Data.Name;
                packaging.Description     = result.Data.Description;
                packaging.DateCreated     = result.Data.CreatedAt;
                packaging.DateLastUpdated = result.Data.LastUpdated;
                return(View(packaging));
            }
            catch (Exception ex)
            {
                Alert($"Error! {ex.Message}", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                return(View(packaging));
            }
        }
Пример #2
0
        public async Task <ActionResult> Delete(Guid id, PackagingDetailsViewModel request)
        {
            if (!ModelState.IsValid)
            {
                Alert("Bad Request", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                return(View());
            }
            if (id == null)
            {
                Alert($"Invalid Request", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                return(View());
            }
            try
            {
                var result = await _packagingService.Delete(id);

                if (!result.Success)
                {
                    Alert($"Error! {result.Message}", NotificationType.info, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                    return(View());
                }
                Alert($"Packaging Deleted Successfully", NotificationType.success, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                Alert($"Error Occurred While processing the request", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                return(View());
            }
        }