Пример #1
0
        public async Task <ActionResult> Delete(Guid id, ListRegionViewModel 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 _regionService.Delete(id);

                if (result.Success)
                {
                    Alert($"Region Deleted Successfully", NotificationType.success, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                    return(RedirectToAction(nameof(Index)));
                }
                else
                {
                    Alert($"Error: {result.Message}", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                    return(View());
                }
            }
            catch
            {
                Alert($"Error Occurred While processing the request", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                return(View());
            }
        }
Пример #2
0
        // GET: Regions/Delete/5
        public async Task <ActionResult> Delete(Guid id)
        {
            if (id == null)
            {
                Alert($"Invalid Request", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                return(View());
            }
            try
            {
                var result = await _regionService.FindById(id);

                if (result.Success)
                {
                    var regionResource = new ListRegionViewModel
                    {
                        RegionId          = result.Data.Id,
                        RegionCode        = result.Data.Code,
                        RegionDescription = result.Data.Description,
                        RegionName        = result.Data.Name,
                        DateCreated       = result.Data.CreatedAt,
                        DateLastUpdated   = result.Data.LastUpdated
                    };

                    return(View(regionResource));
                }
                else
                {
                    Alert($"Error! : {result.Message}", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                    return(View());
                }
            }
            catch (Exception ex)
            {
                Alert($"An Error Occurred While Fetching The Requested Resource. {ex.Message}", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                return(View());
            }
        }