Beispiel #1
0
        public async Task Edit(EditCategoryVMRequest entity)
        {
            var response = await _httpService.Put <EditCategoryVMRequest>(url, entity);

            if (!response.Success)
            {
                throw new ApplicationException(await response.GetBody());
            }
        }
        public async Task <ActionResult> Put(EditCategoryVMRequest entity)
        {
            #region Start the watch
            var watch = new Stopwatch();
            watch.Start();
            #endregion

            var result = await _entityServices.Put(entity);

            #region End the watch
            watch.Stop();
            result.Meta.TotalProcessingTime = watch.ElapsedMilliseconds;
            #endregion

            return(Ok(result));
        }
Beispiel #3
0
        public async Task <ApiResponse> Put(EditCategoryVMRequest entity)
        {
            try
            {
                var entityDB = await _entityRepository.GetByIdAsync(entity.Id);

                if (!string.IsNullOrWhiteSpace(entity.Image))
                {
                    if (entityDB.Image != null)
                    {
                        await _fileService.DeleteFile(entityDB.Image, path);
                    }

                    var entityImage = Convert.FromBase64String(entity.Image);
                    entityDB.Image = await _fileService.EditFile(entityImage, "jpg", path, entityDB.Image, entityDB.Code);
                }
                entityDB.Name_ar        = entity.Name_ar;
                entityDB.Name_en        = entity.Name_en;
                entityDB.Name_fr        = entity.Name_fr;
                entityDB.Name_ru        = entity.Name_ru;
                entityDB.Name_tr        = entity.Name_tr;
                entityDB.Description_ar = entity.Description_ar;
                entityDB.Description_en = entity.Description_en;
                entityDB.Description_fr = entity.Description_fr;
                entityDB.Description_ru = entity.Description_ru;
                entityDB.Description_tr = entity.Description_tr;
                entityDB.Status         = entity.Status;
                await _entityRepository.UpdateAsync(entityDB);

                return(ApiResponse.Create(HttpStatusCode.OK, null));
            }
            catch (Exception)
            {
                return(ApiResponse.Create(HttpStatusCode.InternalServerError, null, "InternalServerError_Error"));
            }
        }