public async Task <IActionResult> Create([FromBody] LocationDTO obj) { var createdEntity = await _locationService.CreateAsync(obj); return(createdEntity != null ? CreatedAtAction(nameof(Create), createdEntity) : (IActionResult)BadRequest()); }
public async Task <ActionResult> AddLocation([FromBody] CreateLocationDto location) { if (!await _deviceRepository.ExistByPhoneId(location.DeviceId)) { return(NotFound("Wrong device ID.")); } return(CreatedAtAction(nameof(AddLocation), await _locationService.CreateAsync(location))); }
public async Task <IActionResult> Create(LocationCreateViewModel model) { if (ModelState.IsValid) { var location = new Location { Id = model.Id, LocationName = model.LocationName, DepartmentId = model.DepartmentId, PositionJobId = model.PositionJobId, Status = true }; await _locationService.CreateAsync(location); return(RedirectToAction(nameof(Index))); } return(View()); }
public async Task <IActionResult> CreateLocationAsync(CreateLocationViewModel model) { try { LocationDto location = new LocationDto { Title = model.Title }; await locationService.CreateAsync(location); return(RedirectToAction("LocationsList", "Location")); } catch (Exception ex) { ErrorViewModel errorModel = new ErrorViewModel(); errorModel.ErrorMessage = ex.Message.ToString(); return(View("Views/Shared/Error.cshtml", errorModel)); } }
public async Task <IActionResult> Create([FromBody] LocationDTO obj) { return(CreatedAtAction(nameof(Create), await _locationService.CreateAsync(obj))); }