//GET:Finding/Edit/{id}
        public ActionResult Edit(int id)
        {
            var service = new FindingService();
            var detail  = service.GetFindingById(id);
            var model   = new FindingEdit
            {
                FindingId   = detail.FindingId,
                Category    = detail.Category,
                SubType     = detail.SubType,
                Size        = detail.Size,
                Color       = detail.Color,
                Association = detail.Association,
                Quantity    = detail.Quantity,
                Cost        = detail.Cost,
                Description = detail.Description,
                LocationId  = detail.LocationId,
                SourceId    = detail.SourceId,
                FileAsBytes = detail.FileAsBytes,
                ImageFile   = detail.ImageFile
            };

            return(View(model));
        }
        //___________________________Put-Update____________
        public bool UpdateFinding(FindingEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity = ctx.Findings
                             .Single(e => e.FindingId == model.FindingId);
                entity.Category    = model.Category;
                entity.SubType     = model.SubType;
                entity.Size        = model.Size;
                entity.Color       = model.Color;
                entity.Association = model.Association;
                entity.Quantity    = model.Quantity;
                entity.Cost        = model.Cost;
                entity.LocationId  = model.LocationId;
                entity.SourceId    = model.SourceId;
                entity.Description = model.Description;
                if (model.File != null)
                {
                    entity.File = _FileService.ConvertToBytes(model.File);
                }

                return(ctx.SaveChanges() == 1);
            }
        }
        public ActionResult Edit(int id, FindingEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            HttpPostedFileBase file = Request.Files["ImageData"];

            if (model.FindingId != id)
            {
                ModelState.AddModelError("", "ID# Mismatch");
                return(View(model));
            }
            var service = new FindingService();

            if (service.UpdateFinding(model))
            {
                TempData["SaveResult"] = "Your finding was updated.";
                return(RedirectToAction("Index"));
            }
            ;
            ModelState.AddModelError("", "Your finding could not be updated.");
            return(View(model));
        }