public JsonResult DeleteFile(string id)
        {
            if (String.IsNullOrEmpty(id))
            {
                Response.StatusCode = (int)HttpStatusCode.BadRequest;
                return(Json(new { Result = "Error" }));
            }
            try
            {
                Guid          guid          = new Guid(id);
                FileInvDetail fileInvDetail = db.FileInvDetails.Find(guid);
                if (fileInvDetail == null)
                {
                    Response.StatusCode = (int)HttpStatusCode.NotFound;
                    return(Json(new { Result = "Error" }));
                }

                //Remove from database
                db.FileInvDetails.Remove(fileInvDetail);
                db.SaveChanges();

                //Delete file from the file system
                var path = Path.Combine(Server.MapPath("~/images/"), fileInvDetail.Id + fileInvDetail.Extension);
                if (System.IO.File.Exists(path))
                {
                    System.IO.File.Delete(path);
                }
                return(Json(new { Result = "OK" }));
            }
            catch (Exception ex)
            {
                return(Json(new { Result = "ERROR", Message = ex.Message }));
            }
        }
        //public ActionResult Create([Bind(Include = "InventoryTransferId,TransferDateTime,InvLocationId,FinishInvLocationId,CustomerPn,PartDescription,TransferFromQty,TransferToQty,Carrier,TrackingInfo,ShipToAddress,Notes")] InventoryTransfer inventoryTransfer)
        public ActionResult Create(InventoryTransfer inventoryTransfer)
        {
            if (ModelState.IsValid)
            {
                List <FileInvDetail> fileInvDetails = new List <FileInvDetail>();
                for (int i = 0; i < Request.Files.Count; i++)
                {
                    var file = Request.Files[i];

                    if (file != null && file.ContentLength > 0)
                    {
                        var           fileName      = Path.GetFileName(file.FileName);
                        FileInvDetail fileInvDetail = new FileInvDetail()
                        {
                            FileName  = fileName,
                            Extension = Path.GetExtension(fileName),
                            Id        = Guid.NewGuid()
                        };
                        fileInvDetails.Add(fileInvDetail);

                        var path = Path.Combine(Server.MapPath("~/images/"), fileInvDetail.Id + fileInvDetail.Extension);
                        file.SaveAs(path);
                    }
                }

                inventoryTransfer.FileInvDetails = fileInvDetails;
                db.InventoryTransfers.Add(inventoryTransfer);
                db.SaveChanges();
                //return Redirect(returnUrl);
                return(RedirectToAction("Index"));
            }
            return(View());
            //return View(inventoryTransfer);
        }
        //public ActionResult Edit([Bind(Include = "InventoryTransferId,TransferDateTime,InvLocationId,FinishInvLocationId,CustomerPn,PartDescription,TransferFromQty,TransferToQty,Carrier,TrackingInfo,ShipToAddress,Notes")] InventoryTransfer inventoryTransfer)
        public ActionResult Edit(InventoryTransfer inventoryTransfer)
        {
            if (ModelState.IsValid)
            {
                //New Files
                for (int i = 0; i < Request.Files.Count; i++)
                {
                    var file = Request.Files[i];

                    if (file != null && file.ContentLength > 0)
                    {
                        var           fileName      = Path.GetFileName(file.FileName);
                        FileInvDetail fileInvDetail = new FileInvDetail()
                        {
                            FileName            = fileName,
                            Extension           = Path.GetExtension(fileName),
                            Id                  = Guid.NewGuid(),
                            InventoryTransferId = inventoryTransfer.InventoryTransferId
                        };
                        var path = Path.Combine(Server.MapPath("~/images/"), fileInvDetail.Id + fileInvDetail.Extension);
                        file.SaveAs(path);

                        db.Entry(fileInvDetail).State = EntityState.Added;
                    }
                }

                db.Entry(inventoryTransfer).State = EntityState.Modified;
                db.SaveChanges();
                //return Redirect(returnUrl);
                return(RedirectToAction("Index"));
            }
            return(View());
            //return View(inventoryTransfer);
        }