public async Task CreateAsync(CreatePositionViewModel positionModel) { var position = _mapper.Map <Position>(positionModel); position.Id = Guid.NewGuid(); await _positionRepository.CreateAsync(position); }
public async Task <IActionResult> Create([FromBody] CreatePositionViewModel vm) { var result = await _services.CreateAsync(_mapper.Map <DirectoryDTO>(vm)); if (result.IsValid) { await _systemAuditService.AuditAsync(User.GetEmail(), _accessor.GetIp(), Operations.Insert, Tables.Position); return(CreatedAtRoute("GetPosition", new { version = "1.0", controller = "Position", id = result.Result }, vm)); } return(UnprocessableEntity(result.ErrorsList)); }
public async Task <IActionResult> Create([FromBody] CreatePositionViewModel vm) { if (ModelState.IsValid) { var result = await _services.CreateAsync(_mapper.Map <DirectoryDTO>(vm)); if (result.IsValid) { await _systemAuditService.AuditAsync(User.GetEmail(), _accessor.GetIp(), Operations.Insert, Tables.Position); return(Ok(result)); } return(BadRequest(result)); } return(BadRequest()); }
public async Task <IActionResult> Create(CreatePositionViewModel vm) { if (ModelState.IsValid) { var result = await _services.CreateAsync(_mapper.Map <DirectoryDTO>(vm)); if (result.IsValid) { await _systemAuditService.AuditAsync(User.GetEmail(), _accessor.GetIp(), Operations.Insert, Tables.Position); return(RedirectToAction("Index")); } TempData["ErrorsList"] = result.ErrorsList; } return(View(vm)); }
public IActionResult Post([FromBody] CreatePositionViewModel createPositionViewModel) { try { PositionApplicationRole position = new PositionApplicationRole() { Id = createPositionViewModel.ID, Name = createPositionViewModel.Name }; iPositionRepository.CreatePosition(position); Uri uri = new Uri(Url.Link("GetPositionByID", new { Id = position.Id })); iUnitOfWork.Save(); return(Created(uri, position.Id.ToString())); } catch (Exception ex) { return(Content(ex.ToString(), BadRequest().ToString())); } }
public async Task <IActionResult> CreatePosition(CreatePositionViewModel model) { if (ModelState.IsValid) { IdentityRole role = new IdentityRole() { Name = model.PositionName }; var result = await roleManager.CreateAsync(role); if (result.Succeeded) { return(RedirectToAction("ListPositions", "Administration")); } foreach (var error in result.Errors) { ModelState.AddModelError("", error.Description); } } return(View(model)); }
public async Task <IActionResult> CreateAsync(CreatePositionViewModel model) { await _positionService.CreateAsync(model); return(Ok()); }