예제 #1
0
        public ActionResult Create(WebForm21a webform21a)
        {
            if (ModelState.IsValid)
            {
                webform21a.Form21aID = Guid.NewGuid();
                db.WebForm21a.Add(webform21a);
                try {
                    db.SaveChanges();
                }
                catch (System.Data.Entity.Validation.DbEntityValidationException e) {
                    var outputLines = new List <string>();
                    foreach (var eve in e.EntityValidationErrors)
                    {
                        outputLines.Add(string.Format(
                                            "{0}: Entity of type \"{1}\" in state \"{2}\" has the following validation errors:",
                                            DateTime.Now, eve.Entry.Entity.GetType().Name, eve.Entry.State));
                        foreach (var ve in eve.ValidationErrors)
                        {
                            outputLines.Add(string.Format(
                                                "- Property: \"{0}\", Error: \"{1}\"",
                                                ve.PropertyName, ve.ErrorMessage));
                        }
                    }
                    System.IO.File.AppendAllLines(@"c:\temp\errors.txt", outputLines);
                    throw;
                }


                return(RedirectToAction("Index"));
            }

            ViewBag.Form21aID = new SelectList(db.WebForm21aServiceBranch, "Form21aID", "OtherService", webform21a.Form21aID);
            return(View(webform21a));
        }
예제 #2
0
        // PUT api/WebForm21aAPI/5
        public HttpResponseMessage PutWebForm21a(Guid id, WebForm21a webform21a)
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }

            if (id != webform21a.Form21aID)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }

            db.Entry(webform21a).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.NotFound, ex));
            }

            return(Request.CreateResponse(HttpStatusCode.OK));
        }
예제 #3
0
        public ActionResult DeleteConfirmed(Guid id)
        {
            WebForm21a webform21a = db.WebForm21a.Find(id);

            db.WebForm21a.Remove(webform21a);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #4
0
        //
        // GET: /WebForm21/Details/5

        public ActionResult Details(Guid id)
        {
            WebForm21a webform21a = db.WebForm21a.Find(id);

            if (webform21a == null)
            {
                return(HttpNotFound());
            }
            return(View(webform21a));
        }
예제 #5
0
 public ActionResult Edit(WebForm21a webform21a)
 {
     if (ModelState.IsValid)
     {
         db.Entry(webform21a).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Form21aID = new SelectList(db.WebForm21aServiceBranch, "Form21aID", "OtherService", webform21a.Form21aID);
     return(View(webform21a));
 }
예제 #6
0
        //
        // GET: /WebForm21/Edit/5

        public ActionResult Edit(Guid id)
        {
            WebForm21a webform21a = db.WebForm21a.Find(id);

            if (webform21a == null)
            {
                return(HttpNotFound());
            }
            ViewBag.Form21aID = new SelectList(db.WebForm21aServiceBranch, "Form21aID", "OtherService", webform21a.Form21aID);
            return(View(webform21a));
        }
예제 #7
0
        // GET api/WebForm21aAPI/5
        public WebForm21a GetWebForm21a(Guid id)
        {
            WebForm21a webform21a = db.WebForm21a.Find(id);

            if (webform21a == null)
            {
                throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound));
            }

            return(webform21a);
        }
예제 #8
0
        public ActionResult Create(WebForm21a webform21a)
        {
            if (ModelState.IsValid)
            {
                webform21a.Form21aID = Guid.NewGuid();
                db.WebForm21a.Add(webform21a);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.Form21aID = new SelectList(db.WebForm21aServiceBranch, "Form21aID", "OtherService", webform21a.Form21aID);
            return(View(webform21a));
        }
예제 #9
0
        // POST api/WebForm21aAPI
        public HttpResponseMessage PostWebForm21a(WebForm21a webform21a)
        {
            if (ModelState.IsValid)
            {
                db.WebForm21a.Add(webform21a);
                db.SaveChanges();

                HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, webform21a);
                response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = webform21a.Form21aID }));
                return(response);
            }
            else
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }
        }
예제 #10
0
        // DELETE api/WebForm21aAPI/5
        public HttpResponseMessage DeleteWebForm21a(Guid id)
        {
            WebForm21a webform21a = db.WebForm21a.Find(id);

            if (webform21a == null)
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound));
            }

            db.WebForm21a.Remove(webform21a);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.NotFound, ex));
            }

            return(Request.CreateResponse(HttpStatusCode.OK, webform21a));
        }
예제 #11
0
        //
        // GET: /WebForm21/Create

        public ActionResult Create()
        {
            WebForm21a newForm = new WebForm21a();

            /* serviceDates
             * var serviceDatesList = new List<WebForm21aServiceDate>();
             * serviceDatesList.Add(new WebForm21aServiceDate() {StartServiceDate = new DateTime(2001,12,1),EndServiceDate = new DateTime(2001,12,1)});
             *
             * newForm.WebForm21aServiceDate = serviceDatesList; */

            var serviceBranchList = new List <WebForm21aServiceBranch>();

            serviceBranchList.Add(new WebForm21aServiceBranch());
            newForm.WebForm21aServiceBranch = serviceBranchList;

            /* serviceBranchDropDown */
            List <SelectListItem> serviceBranchItems = new List <SelectListItem>();

            serviceBranchItems.Add(new SelectListItem
            {
                Text  = "Army",
                Value = "Army"
            });
            serviceBranchItems.Add(new SelectListItem
            {
                Text     = "Navy",
                Value    = "Navy",
                Selected = true
            });
            serviceBranchItems.Add(new SelectListItem
            {
                Text  = "Air Force",
                Value = "Air Force"
            });

            serviceBranchItems.Add(new SelectListItem
            {
                Text  = "Marines",
                Value = "Marines"
            });
            serviceBranchItems.Add(new SelectListItem
            {
                Text  = "Coast Guard",
                Value = "Coast Guard"
            });

            @ViewBag.serviceBranchItems = serviceBranchItems;

            /* employers */
            var employerList = new List <WebForm21aEmployer>();

            employerList.Add(new WebForm21aEmployer());
            //employerList.Add(new WebForm21aEmployer());
            newForm.WebForm21aEmployer = employerList;

            /* education */
            var educationList = new List <WebForm21aEducation>();

            educationList.Add(new WebForm21aEducation());
            //educationList.Add(new WebForm21aEducation());
            newForm.WebForm21aEducation = educationList;

            /* barMembership */
            var barMembershipList = new List <WebForm21aBarMembership>();

            barMembershipList.Add(new WebForm21aBarMembership());
            //barMembershipList.Add(new WebForm21aBarMembership());
            newForm.WebForm21aBarMembership = barMembershipList;

            /* practiceMembership */
            var practiceMembershipList = new List <WebForm21aPracticeMembership>();

            practiceMembershipList.Add(new WebForm21aPracticeMembership());
            //practiceMembershipList.Add(new WebForm21aPracticeMembership());
            newForm.WebForm21aPracticeMembership = practiceMembershipList;


            /* set bits to false - because nulls don't get handled well by HtmlHelper.RadioButtonFor*/
            if (newForm.IsBarMember == null)
            {
                newForm.IsBarMember = false;
            }
            if (newForm.IsPracticing == null)
            {
                newForm.IsPracticing = false;
            }
            if (newForm.WasConvicted == null)
            {
                newForm.WasConvicted = false;
            }
            if (newForm.WasConvictedMilitary == null)
            {
                newForm.WasConvictedMilitary = false;
            }
            if (newForm.IsCharged == null)
            {
                newForm.IsCharged = false;
            }
            if (newForm.WasExpelled == null)
            {
                newForm.WasExpelled = false;
            }
            if (newForm.WasDisciplined == null)
            {
                newForm.WasDisciplined = false;
            }
            if (newForm.WasTerminated == null)
            {
                newForm.WasTerminated = false;
            }
            if (newForm.HasRepresentedGovt == null)
            {
                newForm.HasRepresentedGovt = false;
            }
            if (newForm.WasBarred == null)
            {
                newForm.WasBarred = false;
            }
            if (newForm.HaveAppliedForAccred == null)
            {
                newForm.HaveAppliedForAccred = false;
            }
            if (newForm.WasAccredTerminated == null)
            {
                newForm.WasAccredTerminated = false;
            }
            if (newForm.IsImpaired == null)
            {
                newForm.IsImpaired = false;
            }
            if (newForm.IsPhysicallyLimited == null)
            {
                newForm.IsPhysicallyLimited = false;
            }
            if (newForm.IsProcessed == null)
            {
                newForm.IsProcessed = false;
            }

            /* references */
            var referenceList = new List <WebForm21aReference>();

            referenceList.Add(new WebForm21aReference());
            referenceList.Add(new WebForm21aReference());
            referenceList.Add(new WebForm21aReference());
            newForm.WebForm21aReference = referenceList;



            //ViewBag.Form21aID = new SelectList(db.WebForm21aServiceBranch, "Form21aID", "OtherService");
            return(View(newForm));
        }