public async Task <ActionResult> Create(Order order, HttpPostedFileBase file)
        {
            try
            {
                if (ModelState.IsValid && file != null)
                {
                    var fileUrl = Upload(file);
                    if (!string.IsNullOrEmpty(fileUrl))
                    {
                        order.FileName     = file.FileName;
                        order.CreatedDate  = DateTime.UtcNow;
                        order.ModifiedDate = DateTime.UtcNow;
                        order.UserId       = User.Identity.GetUserId();
                        order.Url          = fileUrl;
                        db.Orders.Add(order);
                        await db.SaveChangesAsync();

                        return(RedirectToAction("Index"));
                    }
                }
            }
            catch (Exception ex)
            {
                CloudBlobContainer blobContainer = blobStorageServices.GetCloudBlobContainer();
                CloudBlockBlob     blob2         = blobContainer.GetBlockBlobReference("logs.txt");
                blob2.UploadText(ex.ToString());
                return(View(order));
            }
            return(View(order));
        }
        public ActionResult Create([Bind(Include = "Id,JobName,Image,Quota,Description,CreatedBy,DateTime,CurrentApplicant,Status,ExpiredDate,CategoryName")] JobMaster jobMaster, HttpPostedFileBase image)
        {
            //JobMaster x = new JobMaster();

            if (image.ContentLength > 0)
            {
                CloudBlobContainer blobContainer = _blobStorageService.GetCloudBlobContainer();
                CloudBlockBlob     blob          = blobContainer.GetBlockBlobReference(image.FileName);
                blob.UploadFromStream(image.InputStream);
                var uri = blob.Uri.AbsoluteUri;
                jobMaster.Image = uri;
            }


            if (ModelState.IsValid)
            {
                jobMaster.CreatedBy = User.Identity.Name;

                db.JobMasters.Add(jobMaster);
                db.SaveChanges();
                //return RedirectToAction("Details");
            }
            else //abis if di guard jangan langsung masuk RedirectToAction, errornya jadi gak ketangkep
            {
                Response.StatusCode = 400;
                return(Content("Model State is Invalid! Please re-check your form!"));
            }

            //return View(jobMaster);
            return(RedirectToAction("Details", new { id = jobMaster.Id }));
        }
        public ActionResult Upload()
        {
            CloudBlobContainer container = _blobStorageServices.GetCloudBlobContainer();
            List <string>      blobs     = new List <string>();

            foreach (var blobItem in container.ListBlobs())
            {
                blobs.Add(blobItem.Uri.ToString());
            }
            return(View(blobs));
        }