public void CreateNewIssue(CreateIssueModel model, out int issueId) { Issue newIssue = CustomMapper.Map <CreateIssueModel, Issue>(model); newIssue.ReportedDate = DateTime.UtcNow; _issueRepository.Create(newIssue, out issueId); }
public IssueDto Create(IssueDto issueDTO) { var issue = _mapper.Map <Issue>(issueDTO); _issueRepository.Create(issue); _issueRepository.SaveChanges(); return(_mapper.Map <IssueDto>(_issueRepository.GetAllDetails(issue.Id))); }
public void Create(Issue issue) { issue.Id = _guidProxy.NewGuid(); issue.LastUpdate = _dateTimeProxy.Now(); issue.CreationTime = _dateTimeProxy.Now(); var dto = ConvertToDto(issue); _issueRepository.Create(dto); }
public HttpResponseMessage CreateIssue(NewIssueVM vm) { ApiResult result; try { var model = new IssueModel { LocationId = vm.LocationId, Title = vm.Title, Description = vm.Description, Longitude = vm.Longitude, Latitude = vm.Latitude, Status = vm.Status, Severity = vm.Severity }; _issueRepository.Create(model, User.Identity.Name); return(Request.CreateResponse(HttpStatusCode.OK, new ApiResponse { Result = ApiResult.Success, JsonContent = JsonConvert.SerializeObject(new { Id = model.Id }, Formatting.None) })); } catch (LocationNotFoundException) { result = ApiResult.LocationNotFound; } catch (UserNotFoundException) { result = ApiResult.UserNotFound; } catch (UnauthorizedAccessException) { return(new HttpResponseMessage(HttpStatusCode.Unauthorized)); } catch (InvalidIssueSeverityException) { result = ApiResult.InvalidIssueSeverity; } catch (InvalidIssueStatusException) { result = ApiResult.InvalidIssueStatus; } catch (Exception) { return(new HttpResponseMessage(HttpStatusCode.InternalServerError)); } return(Request.CreateResponse(HttpStatusCode.OK, new ApiResponse { Result = result })); }
public async Task <ActionResult <Issue> > CreateIssue([FromBody] Issue issue) { await _repository.Create(issue); return(CreatedAtRoute("GetIssue", new { id = issue.Id }, issue)); }
public async Task <ActionResult <Issues> > CreateUser([FromBody] Issues issue) //we are expecting http request and inside of request we expect product body and .net core will auto convert jason to object { await _repository.Create(issue); return(CreatedAtRoute("GetIssue", new { id = issue.Id }, issue)); }