Esempio n. 1
0
        public ActionResult Form14242(Form14242Model vm)
        {
            vm.ReportedDate = DateTime.Now;

            vm.Artifacts = GetArtifacts(Request);
            using (Repository store = new Repository())
            {
                store.Form14242.Add(vm);
                try
                {
                    store.SaveChanges();
                }
                catch (DbEntityValidationException dbEx)
                {
                    foreach (var validationErrors in dbEx.EntityValidationErrors)
                    {
                        foreach (var validationError in validationErrors.ValidationErrors)
                        {
                            Trace.TraceInformation("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage);
                        }
                    }
                    throw dbEx;
                }
            }

            return RedirectToAction("Index");
        }
Esempio n. 2
0
        public ActionResult DownloadFile(int id)
        {
            using (Repository store = new Repository())
            {
                Artifact file = store.Artifacts.FirstOrDefault(f => f.ID == id);

                if (file == null) { throw new HttpException(404, "HTTP/1.1 404 Not Found"); }

                return File(file.FileContents, file.ContentType);

            }
        }
Esempio n. 3
0
 public ActionResult View(int id)
 {
     Form14242Model form = null;
     using (Repository store = new Repository())
     {
         form = store.Form14242.Include("Preparers").Include("Promoters").Include("Artifacts").Where(p => p.ID == id).FirstOrDefault();
     }
     if (form == null)
     {
         throw new HttpException(404, string.Format("No Form found with the id of {0}", id));
     }
     return View(form);
 }
Esempio n. 4
0
 public ActionResult ViewAll()
 {
     IEnumerable<Form14242Model> forms = new List<Form14242Model>();
     using (Repository store = new Repository())
     {
         forms = store.Form14242.Select(p => p).ToList();
     }
     return View(forms);
 }