Example #1
0
        public async Task <ActionResult> Delete(Guid id, AnchorDetailsViewModel request)
        {
            if (!ModelState.IsValid)
            {
                Alert("Bad Request", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                return(RedirectToAction(nameof(Delete), new { id = request.Id }));
            }
            if (id == null)
            {
                Alert($"Invalid Request", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                return(RedirectToAction(nameof(Delete), new { id = request.Id }));
            }
            try
            {
                var result = await _anchorService.Delete(id);

                if (!result.Success)
                {
                    Alert($"Error! {result.Message}", NotificationType.info, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                    return(RedirectToAction(nameof(Delete), new { id = request.Id }));
                }
                Alert($"Tier 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(RedirectToAction(nameof(Delete), new { id = request.Id }));
            }
        }
Example #2
0
        // GET: Anchors/Details/5
        public async Task <ActionResult> Details(Guid id)
        {
            var anchor = new AnchorDetailsViewModel();

            try
            {
                var result = await _anchorService.FindByIdInclusive(id, x => x.Include(p => p.EntityType).Include(w => w.Address).ThenInclude(f => f.Region).ThenInclude(c => c.Country).Include(q => q.Setting).Include(g => g.ContactPerson));

                if (!result.Success)
                {
                    Alert($"Error! {result.Message}", NotificationType.info, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                    return(View(anchor));
                }
                var anchor1 = new AnchorDetailsViewModel
                {
                    Id                        = result.Data.Id,
                    Code                      = result.Data.Code,
                    AddressEmail              = result.Data.Address?.EmailAddress,
                    AddressPhone              = result.Data.Address?.PhoneNumber,
                    City                      = result.Data.Address.City,
                    ContactEmail              = result.Data.ContactPerson?.ContactEmail,
                    ContactPhone              = result.Data.ContactPerson?.ContactPhone,
                    CountryName               = result.Data.Address?.Region?.Country?.Name,
                    Name                      = result.Data.Name,
                    DateCreated               = result.Data.CreatedAt,
                    DateLastUpdated           = result.Data.LastUpdated,
                    DateOfRegistration        = result.Data.DateOfRegistration,
                    Description               = result.Data.Description,
                    EntityTypeName            = result.Data.EntityType?.Name,
                    FirstName                 = result.Data.ContactPerson.FirstName,
                    LastName                  = result.Data.ContactPerson.FirstName,
                    LicenceNumber             = result.Data.LicenceNumber,
                    PurchaseOrderAutoApproval = result.Data.Setting.PurchaseOrderAutoApproval,
                    SaleOrderAutoApproval     = result.Data.Setting.SaleOrderAutoApproval,
                    RegionName                = result.Data.Address?.Region.Name,
                    RegistrationNumber        = result.Data.RegistrationNumber,
                    SettingDescription        = result.Data.Setting?.Description,
                    SettingName               = result.Data.Setting?.Name,
                    Street                    = result.Data.Address?.Street
                };

                var tierResult = await _tierService.FindById(result.Data.TierId);

                if (tierResult.Success)
                {
                    anchor1.TierName = tierResult.Data.Name;
                }
                return(View(anchor1));
            }
            catch (Exception ex)
            {
                Alert($"Error! {ex.Message}", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                return(View(anchor));
            }
        }