示例#1
0
        public async Task <ServiceResponse <GetLocationDTO> > UpdateLocation(UpdateLocationDTO updatedLocation)
        {
            ServiceResponse <GetLocationDTO> serviceResponse = new ServiceResponse <GetLocationDTO>();

            try
            {
                Location l = await _context.Locations.Where(l => l.IsDeleted == false)
                             .FirstOrDefaultAsync(l => l.Id == updatedLocation.Id);

                l.SquareMeters = updatedLocation.SquareMeters;

                if (updatedLocation.Capacity != 0)
                {
                    l.Capacity = updatedLocation.Capacity;
                }
                if (updatedLocation.Address != null)
                {
                    l.Address = updatedLocation.Address;
                }


                _context.Locations.Update(l);
                await _context.SaveChangesAsync();

                serviceResponse.Data = _mapper.Map <GetLocationDTO>(l);
            }
            catch (Exception exc)
            {
                serviceResponse.Success = false;
                serviceResponse.Message = exc.Message;
            }

            return(serviceResponse);
        }
示例#2
0
        public async Task UpdateLocation(UpdateLocationDTO input)
        {
            var location = _mapper.Map <Location>(input);

            location.Project = await _projectRepository.GetById(input.ProjectId);

            await _repository.Update(location.Id, location);
        }
示例#3
0
        public async Task <IActionResult> Update(UpdateLocationDTO l)
        {
            ServiceResponse <GetLocationDTO> response = await _locationService.UpdateLocation(l);

            if (response.Data == null)
            {
                return(NotFound(response));
            }
            return(Ok(response));
        }
示例#4
0
        public async Task <IActionResult> UpdateLocation([FromBody] UpdateLocationDTO updatedLocation)
        {
            var result = await LocationActor.Ask(
                new AskToUpdateLocation(
                    updatedLocation.Fields,
                    updatedLocation.Location
                    ),
                TimeSpan.FromSeconds(15)
                );

            return(ValidateActorResult(result));
        }
示例#5
0
        public async Task <IActionResult> UpdateLocation(UpdateLocationDTO input)
        {
            try
            {
                await _locationService.UpdateLocation(input);

                return(Ok("The process is success"));
            }
            catch (Exception)
            {
                return(BadRequest("An error occurred during the updating process. Please try again !"));
            }
        }
        public async Task <IActionResult> PutLocation(int id, UpdateLocationDTO location)
        {
            if (id != location.Id)
            {
                return(BadRequest());
            }

            var completed = await locationsService.PutLocation(id, mapper.Map <Location>(location));

            if (!completed)
            {
                return(NotFound());
            }
            else
            {
                return(Ok());
            }
        }