//GET: Finding/Details/{id}
        public ActionResult Details(int id)
        {
            var service = new FindingService();
            var model   = service.GetFindingById(id);

            return(View(model));
        }
        // GET: Finding/Index
        public ActionResult Index()
        {
            var findingService = new FindingService();
            var model          = findingService.GetFindings();

            return(View(model));
        }
        public ActionResult IndexTotal()
        {
            var findingService      = new FindingService();
            HttpPostedFileBase file = Request.Files["ImageData"];
            var model = findingService.GetFindingSubTotal();

            return(View(model));
        }
        public ActionResult DeletePost(int id)
        {
            var service = new FindingService();

            service.DeleteFinding(id);
            TempData["SaveResult"] = "Your finding was deleted.";
            return(RedirectToAction("Index"));
        }
        public ActionResult Create(FindingCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            HttpPostedFileBase file = Request.Files["ImageData"];
            var service             = new FindingService();

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

            return(View(model));
        }
        Task <bool> IRequestHandler <UpdateOapChecklistQuestionFindingRequest, bool> .Handle(UpdateOapChecklistQuestionFindingRequest request, CancellationToken cancellationToken)
        {
            var existingFinding = FindingService.Get(request.Finding.Id);

            if (existingFinding == null)
            {
                throw new ApplicationException($"UpdateFindingHandler: Finding with Id {request.Finding.Id} does not exist.");
            }

            //AutoMapper to Map the fields
            Mapper.Map(request.Finding, existingFinding);

            using (var ts = new TransactionScope())
            {
                var updatedFinding = FindingService.Update(existingFinding);

                ts.Complete();
            }
            return(Task.FromResult(true));
        }
        //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));
        }
        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));
        }
Example #9
0
 public FindingController(DBContext context)
 {
     service = new FindingService(context);
 }