コード例 #1
0
        public void SaveOrUpdateBackground(BackGroundModel model)
        {
            byte[] image          = null;
            string imgContentType = null;

            if (model.ImgFile != null)
            {
                using (var memoryStream = new MemoryStream())
                {
                    model.ImgFile.CopyTo(memoryStream);
                    image = memoryStream.ToArray();
                }
                imgContentType = model.ImgFile.ContentType;
            }

            var parms = new Tuple <string, object>[] {
                new Tuple <string, object>("@id", Guid.NewGuid()),
                new Tuple <string, object>("@graphicChartId", model.GraphicChartId),
                new Tuple <string, object>("@width", model.Width),
                new Tuple <string, object>("@height", model.Height),
                new Tuple <string, object>("@bgSizeOption", model.BgSizeOption),
                new Tuple <string, object>("@image", image),
                new Tuple <string, object>("@imgContentType", imgContentType),
            };

            var sql = "delete from background where graphicChartId=@graphicChartId;"
                      + "insert into background(id,graphicChartId,width,height,bgSizeOption,image,imgContentType)"
                      + "values(@id,@graphicChartId,@width,@height,@bgSizeOption,@image,@imgContentType);";

            this.dbAccess.ExecuteNonQuery(sql, parms);
        }
コード例 #2
0
 public ActionResult <StatusCodeResult> Post([FromForm] BackGroundModel value)
 {
     this.backgroundSvc.SaveOrUpdateBackground(value);
     return(Ok());
 }