示例#1
0
        /// <summary>
        /// Оновлює зображення
        /// </summary>
        /// <param name="imageDto">Екземпляр зображення</param>
        public void UpdateImage(ImagesDtoModel imageDto)
        {
            var         mapper = new MapperConfiguration(cfg => cfg.CreateMap <ImagesDtoModel, ImagesModel>()).CreateMapper();
            ImagesModel image  = mapper.Map <ImagesModel>(imageDto);

            var results = imagesValidator.Validate(image);

            if (imagesValidator.Validate(image).IsValid)
            {
                imagesRepository.Update(image);
            }
            else
            {
                throw new Exception("Помилка валідації зображення:" + Environment.NewLine +
                                    ValidationResultsHelper.GetValidationErrors(results));
            }
        }
示例#2
0
        public object Put(JObject updatedJSON)
        {
            object json;

            try
            {
                IDictionary <String, object> updated = updatedJSON.ToObject <IDictionary <String, object> >();

                User currentUser = UsersManager.GetCurrentUser(Request);

                string messageError = "";
                Img    putting      = repository.Update(updated, currentUser, ref messageError);

                if (putting != null)
                {
                    json = new
                    {
                        total   = 1,
                        data    = putting,
                        success = true
                    };
                }
                else
                {
                    json = new
                    {
                        message = messageError,
                        success = false
                    };
                }
            }
            catch (Exception ex)
            {
                LogManager.Write("ERROR:" + Environment.NewLine + "\tMETHOD = " + this.GetType().FullName + "." + MethodBase.GetCurrentMethod().Name + Environment.NewLine + "\tMESSAGE = " + ex.Message);

                json = new
                {
                    message = ex.Message,
                    success = false
                };
            };

            return(json);
        }
示例#3
0
 public bool UpdateImage(int ID, string text, DateTime CreatedDate, int DBCode, string Code, string FilePath)
 {
     try
     {
         _imagesRepository.Update(new Images
         {
             CreatedDate = CreatedDate,
             DBCode      = DBCode,
             Code        = Code,
             FilePath    = FilePath,
             ID          = ID,
             ModifyDate  = DateTime.Now,
             Text        = text
         });
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }