예제 #1
0
        public IActionResult Update([FromBody] YachtTourUpdateModel model, string encryptedId)
        {
            var id = DecryptValue(encryptedId);

            if (id == 0)
            {
                return(BadRequest());
            }
            var baseresponse = _yachtToursServices.Update(model, id);

            if (baseresponse.IsSuccessStatusCode)
            {
                return(Ok(baseresponse));
            }
            return(BadRequest());
        }
예제 #2
0
        public BaseResponse <bool> Update(YachtTourUpdateModel model, int tourId)
        {
            try
            {
                var entity = Find(tourId);
                if (entity == null)
                {
                    return(BaseResponse <bool> .BadRequest());
                }

                //entity.InjectFrom(model);
                entity = _mapper.Map <YachtTourUpdateModel, YachtTours>(model, entity);
                entity = GenerateForUpdate(entity);
                _db.Update(entity);
                return(_db.SaveChanges() > 0 ? BaseResponse <bool> .Success(true) : BaseResponse <bool> .BadRequest());
            }
            catch (Exception ex)
            {
                return(BaseResponse <bool> .InternalServerError(message : ex.Message, fullMsg : ex.StackTrace));
            }
        }