public IActionResult Download(Guid id) { var fileEntry = _fileEntryService.GetById(id); var content = _fileManager.Read(fileEntry); return(File(content, MediaTypeNames.Application.Octet, WebUtility.HtmlEncode(fileEntry.FileName))); }
public IActionResult GetIssue(int id) { var issue = issueService.GetById(id); var issueDto = mapper.Map <IssueDto>(issue); return(Ok(new DtoOutput <IssueDto>(issueDto))); }
public IActionResult Get(int id) { var departmentFromRepo = departmentService.GetById(id); var outputDto = mapper.Map <DepartmentDto>(departmentFromRepo); return(Ok(new DtoOutput <DepartmentDto>(outputDto))); }
public IActionResult Get(int id) { var categoryFromRepo = subCategoryService.GetById(id); var outputDto = mapper.Map <SubCategoriesDto>(categoryFromRepo); return(Ok(new DtoOutput <SubCategoriesDto>(outputDto))); }
public IActionResult CreateIssue([FromBody] IssueForCreateDto model) { var issueEntity = new Issue { Issues = model.Issues, Latitude = model.latitude, Longitude = model.longitude, Location = model.Location, Status = "pending", Priority = model.Priority, ImageUrl = model.ImageUrl, DateCreated = DateTime.Now, IsDeleted = false, }; var result = context.Issues.Add(issueEntity); /*iterating through the list of subcategory Id we get from frontend. * For eg. potholes,oneway, donotenter * we get subCategoryId=[10,11,2] */ foreach (var id in model.SubCategoryId) { //Creating new instance of intermediate table. var issueSubCategory = new IssueSubCategory(); // Retrieving subCategory object based on subCategory Id. var subCategory = subCategoryService.GetById(id); //Mapping the SubCategory to Issue. issueSubCategory.Issue = issueEntity; issueSubCategory.SubCategory = subCategory; context.IssueSubCategories.Add(issueSubCategory); } //retrieving list of unique Category for the given subCategory Ids. var categories = issueHelperFunction.GetCategoryFromSubCategory(model.SubCategoryId); //iterating through unique Category. foreach (var category in categories.GroupBy(x => x.Id).Select(y => y.First())) { //creating a new instance of intermediate table. var issueCategory = new IssueCategory(); //Mapping Category to Issue. issueCategory.Category = category; issueCategory.Issue = issueEntity; context.IssueCategories.Add(issueCategory); } try { context.SaveChanges(); return(Ok(new DtoOutput <IssueDto>(null, "Issue Created Successfully", 0))); } catch (Exception ex) { return(BadRequest(new DtoOutput <IssueForCreateDto>(model, "Unable to create issue.", ErrorCode.ISSUE_CREATE_FAILED))); } }
public virtual async Task <IActionResult> GetById([FromRoute] long id) { try { var result = await entityCrudService.GetById(id); return(Ok(result)); } catch (Exception exception) { return(DefaultCatch(exception)); } }
public IActionResult GetById(Guid id) { try { return(Ok(_service.GetById(id))); } catch (EntityNotFoundException ex) { return(NotFound()); } }
public async Task <ActionResult <T> > GetById(int id) { try { var result = await _crudService.GetById(id); return(Ok(result)); } catch (Exception e) { _logger.LogError(e, "Getting {T} with id {$Id} request failed", typeof(T), id); return(BadRequest("Unable to get object by id. If problem persists, contact an administrator")); } }
public async Task <ActionResult <T> > GetById(int id) { try { _logger.LogInformation($"Inicio - {nameof(GetById)} ({nameof(T)})"); var result = await _crudService.GetById(id); _logger.LogInformation($"Fim - {nameof(GetById)} ({nameof(T)})"); return(Ok(result)); } catch (Exception e) { _logger.LogError($"{nameof(GetById)} ({nameof(T)}): {e}"); throw; } }
public IActionResult GetAssigneeById(long id) { return(service.IsInDataBase(id) ? Ok(service.GetById(id)) : StatusCode(404, new ErrorMessage("Assignee not found"))); }
public async Task <IActionResult> Get(Guid id) { var entity = await service.GetById(id); return(Ok(entity)); }
public async Task <L2Player> GetById(int characterId) { var characterContract = await _characterCrudService.GetById(characterId); return(characterContract.ToPlayer()); }
public virtual T GetById(Guid id) => _service.GetById(id);
public T2 GetById(T1 id) => _service.GetById(id);
public async Task <TEntity> GetById(Guid id) { return(await service.GetById(id)); }
public override async Task RunImpl() { AccountContract account = await _accountCrudService.GetById(_accountId); _login.AwaitAddAccount(account, _key); }
public IActionResult Edit(int id) { PrepareDropdownValues(); return(ResolveEditView(_service.GetById(id))); }