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 })); }
public async Task <IActionResult> Create(int?id, int?appointmentId, int?patientId) { if (appointmentId != null && patientId != null) { throw new AwroNoreException("Can not create invoice for appointment & patient"); } var beautycenter = await _shiftCenterService.GetByIdAsync(CurrentBeautyCenter.Id); if (beautycenter == null || beautycenter.Type != ShiftCenterType.BeautyCenter) { throw new AwroNoreException(Core.Resources.EntitiesResources.Messages.PolyclinicNotFound); } if (id != null) { var invoice = await _invoiceRepository.GetInvoiceByIdAsync(id.Value); if (invoice == null || invoice.Patient.ServiceSupply.ShiftCenterId != CurrentBeautyCenter.Id) { throw new AwroNoreException("Invoice Not Found"); } var model = new InvoiceViewModel { Id = invoice.Id, VisitDate = invoice.VisitDate.ToString("yyyy/MM/dd"), AppointmentId = invoice.AppointmentId, PatientId = invoice.PatientId, Description = invoice.Description }; return(PartialView(model)); } else { var(person, _) = await GetPersonAndServiceSupplyIdAsync(appointmentId, patientId); if (person == null) { throw new AwroNoreException("Person Not Found"); } ViewBag.PersonInfo = CollectPersonInfo(person); var model = new InvoiceViewModel { AppointmentId = appointmentId, PatientId = patientId, VisitDate = DateTime.Now.ToShortDateString() }; return(PartialView(model)); } }