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)));
        }
Пример #2
0
        public IActionResult GetIssue(int id)
        {
            var issue    = issueService.GetById(id);
            var issueDto = mapper.Map <IssueDto>(issue);

            return(Ok(new DtoOutput <IssueDto>(issueDto)));
        }
Пример #3
0
        public IActionResult Get(int id)
        {
            var departmentFromRepo = departmentService.GetById(id);
            var outputDto          = mapper.Map <DepartmentDto>(departmentFromRepo);

            return(Ok(new DtoOutput <DepartmentDto>(outputDto)));
        }
Пример #4
0
        public IActionResult Get(int id)
        {
            var categoryFromRepo = subCategoryService.GetById(id);
            var outputDto        = mapper.Map <SubCategoriesDto>(categoryFromRepo);

            return(Ok(new DtoOutput <SubCategoriesDto>(outputDto)));
        }
Пример #5
0
        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)));
            }
        }
Пример #6
0
        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));
            }
        }
Пример #7
0
 public IActionResult GetById(Guid id)
 {
     try
     {
         return(Ok(_service.GetById(id)));
     }
     catch (EntityNotFoundException ex)
     {
         return(NotFound());
     }
 }
Пример #8
0
        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"));
            }
        }
Пример #9
0
        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;
            }
        }
Пример #10
0
 public IActionResult GetAssigneeById(long id)
 {
     return(service.IsInDataBase(id) ? Ok(service.GetById(id)) : StatusCode(404, new ErrorMessage("Assignee not found")));
 }
Пример #11
0
    public async Task <IActionResult> Get(Guid id)
    {
        var entity = await service.GetById(id);

        return(Ok(entity));
    }
Пример #12
0
        public async Task <L2Player> GetById(int characterId)
        {
            var characterContract = await _characterCrudService.GetById(characterId);

            return(characterContract.ToPlayer());
        }
Пример #13
0
 public virtual T GetById(Guid id) => _service.GetById(id);
Пример #14
0
 public T2 GetById(T1 id) => _service.GetById(id);
Пример #15
0
 public async Task <TEntity> GetById(Guid id)
 {
     return(await service.GetById(id));
 }
Пример #16
0
        public override async Task RunImpl()
        {
            AccountContract account = await _accountCrudService.GetById(_accountId);

            _login.AwaitAddAccount(account, _key);
        }
Пример #17
0
 public IActionResult Edit(int id)
 {
     PrepareDropdownValues();
     return(ResolveEditView(_service.GetById(id)));
 }