Beispiel #1
0
        public async Task <IActionResult> Create([FromBody] LocationDTO obj)
        {
            var createdEntity = await _locationService.CreateAsync(obj);

            return(createdEntity != null
                ? CreatedAtAction(nameof(Create), createdEntity)
                : (IActionResult)BadRequest());
        }
Beispiel #2
0
        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)));
        }
Beispiel #3
0
        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));
            }
        }
Beispiel #5
0
 public async Task <IActionResult> Create([FromBody] LocationDTO obj)
 {
     return(CreatedAtAction(nameof(Create), await _locationService.CreateAsync(obj)));
 }