> [Authorized] ActionResult ChangeLogo (string data)
{uid = HttpContext.Request.Cookies.Get ("uid"). Value; (var fctx = System.IO.File.CreateText (HttpContext.Server.MapPath ("~/app_data /logos/") + uid))
{. Write (data);
} Content ("ok");
}
[HttpPost] ActionResult TakeImageList (Guid location, int offset, int count)
{= offset * count; ctx = new WINEntities (); cnt = ctx.Images.LongCount (); (cnt <15) count = (int) cnt; if (count> 15 ) count = 15; entities = (from image in ctx.Images where image.location == location orderby image.date select image). Skip (offset). Take (count). ToList (); result = new List (); (var entity in entities)
{. Add (new ImageMiniatureModel (entity));
} Json (result);
}
[HttpPost] ActionResult GetImage (Guid id)
{(var ctx = new WINEntities ())
{image = ctx.Images.SingleOrDefault (x => x.id == id); Json (new ImageModel (image));
}
}
[HttpPost] ActionResult SaveImage (Guid id, Guid uid, Guid location, string data)
{(data.IndexOf ("data: image/png; base64,")! = 0) Content ("Замріявся, півник?)"); (var ctx = new WINEntities ())
{
image = null; (uid == Guid.Empty)
{= Guid.Parse (HttpContext.Request ["uid"]);
} (location == Guid.Empty)
{= uid;
} (id == Guid.Empty)
{= Guid.NewGuid (); = new Image ()
{= id, = uid, = location, = DateTime.Now
};. Images.AddObject (image);
}
{= (from img in ctx.Images where img.id == id select img). FirstOrDefault ()?? new Image () {id = Guid.NewGuid (), uid = uid, location = uid}; (image.uid! = uid)
{Content ("Замріявся, півник?)");
}
} (var file = System.IO.File.CreateText (HttpContext.Request.MapPath ("~/app_data/images /") + image.id))
{. Write (data);
} [] min = Convert.FromBase64String (data.Replace ("data: image/png; base64,", "")); (MemoryStream ms = new MemoryStream (min) )
{bmp = new System.Drawing.Bitmap (ms); newX = 64; newY = bmp.VerticalResolution * newX/bmp.HorizontalResolution;. SetResolution (newX, newY);. Flush (); (var memory = new MemoryStream ())
{enc = new EncoderParameters (1);. Param [0] = new EncoderParameter (Encoder.Compression, (long) EncoderValue.CompressionLZW);. Save (memory,. GetImageEncoders (). SingleOrDefault ( x =>...