Exemplo n.º 1
0
        public ActionResult Create([Bind(Include = "EmpName,Salary")] Employee employee, HttpPostedFileBase imageFile)
        {
            if (ModelState.IsValid)
            {
                employee.ImageURL = UploadImage(imageFile);

                db.Employees.Add(employee);
                db.SaveChanges();
                //Convert
                PostMessageToQueue(employee.Id, employee.ImageURL);
                return(RedirectToAction("Index"));
            }
            return(View(employee));
        }
Exemplo n.º 2
0
        public static void GenerateThumbnail(
            [QueueTrigger("thumbnailrequest-poison")] BlobInformation blobInfo,
            [Blob("images/{BlobName}", FileAccess.Read)] Stream input,
            [Blob("images/{BlobNameWithoutExtension}_thumbnail.jpg")] CloudBlockBlob outputBlob, ILogger log)
        {
            using (Stream output = outputBlob.OpenWrite())
            {
                ConvertImageToThumbnailJPG(input, output);
                outputBlob.Properties.ContentType = "image/jpeg";
            }

            using (MyDemoContext db = new MyDemoContext())
            {
                var      id  = blobInfo.EmpId;
                Employee emp = db.Employees.Find(id);
                if (emp == null)
                {
                    throw new Exception(String.Format("EmpId: {0} not found, can't create thumbnail", id.ToString()));
                }
                emp.ThumbnailURL = outputBlob.Uri.ToString();
                db.SaveChanges();
            }
        }