コード例 #1
0
        public async Task <IActionResult> CreateUpdate(int?id = null)
        {
            ViewBag.Cities = _commonUtils.PopulateCitiesList();

            var model = new PharmacyCreateUpdateViewModel
            {
                Id = id,
            };

            if (id != null)
            {
                var pharmacy = await _pharmacyRepository.GetByIdAsync(id.Value);

                if (pharmacy == null)
                {
                    throw new Exception("Pharmacy Not Found");
                }

                model.Name           = pharmacy.Name;
                model.Name_Ku        = pharmacy.Name_Ku;
                model.Name_Ar        = pharmacy.Name_Ar;
                model.Address        = pharmacy.Address;
                model.Address_Ku     = pharmacy.Address_Ku;
                model.Address_Ar     = pharmacy.Address_Ar;
                model.Description    = pharmacy.Description;
                model.Description_Ku = pharmacy.Description_Ku;
                model.Description_Ar = pharmacy.Description_Ar;
                model.GoogleMap_lat  = pharmacy.Location != null && pharmacy.Location?.Y > 0 ? pharmacy.Location?.Y.ToString() : "";
                model.GoogleMap_lng  = pharmacy.Location != null && pharmacy.Location?.X > 0 ? pharmacy.Location?.X.ToString() : "";
                model.CityId         = pharmacy.CityId;
            }

            return(PartialView("CreateUpdate", model));
        }
コード例 #2
0
        public async Task <IActionResult> LoadTable([FromBody] DataTablesParameters param)
        {
            try
            {
                var filtersModel = JsonConvert.DeserializeObject <UserFilterModel>(param.FiltersObject);

                var queryModel = new UsersQueryModel
                {
                    Parameters  = param,
                    FilterModel = filtersModel
                };

                var url = IdentityAPI.Getting.PostQueryAsync(_identityService.IdentityBaseUrl, "user");

                var result = await _identityService.GetAsync <UsersQueryModel, UsersResultDTO>(url, queryModel);

                var users = result.Users.Select(async(x) => new UserListViewModel
                {
                    Id       = x.Id,
                    UserName = x.UserName,
                    Mobile   = x.Mobile,
                    Role     = RolesResource.ResourceManager.GetString(x.Role),
                    Person   = x.PersonId == null ? "" : Lng == Lang.KU ? (await _personService.GetByIdAsync(x.PersonId.Value))?.FullName_Ku :
                               Lng == Lang.AR ? (await _personService.GetByIdAsync(x.PersonId.Value))?.FullName_Ar : (await _personService.GetByIdAsync(x.PersonId.Value))?.FullName,
                    Center = x.CenterId == null ? "" : x.LoginAs == LoginAs.PHARMACYMANAGER ?
                             Lng == Lang.KU ? (await _pharmacyRepository.GetByIdAsync(x.CenterId.Value))?.Name_Ku :
                             Lng == Lang.AR ? (await _pharmacyRepository.GetByIdAsync(x.CenterId.Value))?.Name_Ar : (await _pharmacyRepository.GetByIdAsync(x.CenterId.Value))?.Name
                                                       :
                             Lng == Lang.KU ? (await _shiftCenterService.GetByIdAsync(x.CenterId.Value))?.Name_Ku :
                             Lng == Lang.AR ? (await _shiftCenterService.GetByIdAsync(x.CenterId.Value))?.Name_Ar : (await _shiftCenterService.GetByIdAsync(x.CenterId.Value))?.Name,
                    LockoutStatusHtml = await this.RenderViewToStringAsync("_UserItemLockoutStatus", (x.Id, x.IsLocked)),
                    ActionsHtml       = await this.RenderViewToStringAsync("_UserItemActions", (x.Id, x.IsLocked))
                }).ToList();

                var finalUsers = await Task.WhenAll(users);

                return(new JsonResult(new DataTablesResult <UserListViewModel>
                {
                    Draw = param.Draw,
                    Data = finalUsers.ToList(),
                    RecordsFiltered = result.TotalCount,
                    RecordsTotal = result.TotalCount
                }));
            }
コード例 #3
0
 private async Task <PharmacyTable> GetPharmacyTableById(long id)
 {
     try
     {
         return(await _pharmacyRepository.GetByIdAsync(id));
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }