public async Task <HttpResponseMessage> UpdateSingleFile(int fileId)
        {
            try
            {
                //ItemResponse<int> response = new ItemResponse<int>();
                HttpPostedFile    postedFile = HttpContext.Current.Request.Files[0];
                LogoUpdateRequest model      = new LogoUpdateRequest
                {
                    FileName    = postedFile.FileName,
                    Size        = postedFile.ContentLength,
                    ContentType = postedFile.ContentType
                };
                string contentType = Request.Content.Headers.ContentType.MediaType;

                ServerFileName = string.Format("{0}_{1}{2}",
                                               Path.GetFileNameWithoutExtension(postedFile.FileName),
                                               Guid.NewGuid().ToString(),
                                               Path.GetExtension(postedFile.FileName));
                model.ServerFileName = ServerFileName;

                await SavePostedFile(postedFile);

                _logoService.UpdateLogo(model);
                return(Request.CreateResponse(HttpStatusCode.OK, new SuccessResponse()));
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
            }
        }
Exemplo n.º 2
0
 public void UpdateLogo(LogoUpdateRequest model)
 {
     DataProvider.ExecuteNonQuery("dbo.FileStorage_Update"
                                  , inputParamMapper : delegate(SqlParameterCollection paramCollection)
     {
         paramCollection.AddWithValue("@FileId", model.FileId);
         paramCollection.AddWithValue("@FileName", model.FileName);
         paramCollection.AddWithValue("@Size", model.Size);
         paramCollection.AddWithValue("@ContentType", model.ContentType);
         paramCollection.AddWithValue("@SystemFileName", model.ServerFileName);
     });
 }