Example #1
0
        public async Task <ActionResult> UpdateTrailer(int trailerId, TrailerDTO trailerDto)
        {
            try
            {
                var oldTrailer = await _trailerRepository.GetTrailerById(trailerId);

                if (oldTrailer == null)
                {
                    return(NotFound("$Could not find trailer"));
                }

                var newTrailer = _mapper.Map(trailerDto, oldTrailer);
                _trailerRepository.Update(newTrailer);

                if (await _trailerRepository.Save())
                {
                    return(NoContent());
                }
            }
            catch (Exception e)
            {
                return(this.StatusCode(StatusCodes.Status500InternalServerError, $"Database Failure: {e.Message}"));
            }

            return(BadRequest());
        }
Example #2
0
        //using for active and deactive user
        public void SetStatusTrailer(string id)
        {
            var trailerToRemove = _trailerRepository.Get(c => c.TrailerC == id);

            if (trailerToRemove.IsActive == Constants.ACTIVE)
            {
                trailerToRemove.IsActive = Constants.DEACTIVE;
            }
            else
            {
                trailerToRemove.IsActive = Constants.ACTIVE;
            }

            _trailerRepository.Update(trailerToRemove);

            SaveTrailer();
        }