コード例 #1
0
 public ActionResult Add(TipstaffNPO model)
 {
     if (ModelState.IsValid)
     {
         string controller = genericFunctions.TypeOfTipstaffRecord(model.tipstaffRecordID);
         if (controller == "Warrant")
         {
             Warrant w = db.Warrants.Find(model.tipstaffRecordID);
             w.NPO             = model.NPO;
             db.Entry(w).State = EntityState.Modified;
             db.SaveChanges();
             return(RedirectToAction("Details", "Warrant", new { id = w.tipstaffRecordID }));
         }
         else
         {
             ChildAbduction ca = db.ChildAbductions.Find(model.tipstaffRecordID);
             ca.NPO             = model.NPO;
             db.Entry(ca).State = EntityState.Modified;
             db.SaveChanges();
             return(RedirectToAction("Details", "ChildAbduction", new { id = ca.tipstaffRecordID }));
         }
     }
     else
     {
         return(View(model));
     }
 }
コード例 #2
0
 public ActionResult Edit(SolicitorAdmin model)
 {
     if (ModelState.IsValid)
     {
         db.Entry(model.solicitor).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(model));
 }
 public ActionResult Edit(ChildRelationship childrelationship)
 {
     if (ModelState.IsValid)
     {
         db.Entry(childrelationship).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(childrelationship));
 }
コード例 #4
0
 public ActionResult Edit(DeletedReason model)
 {
     if (ModelState.IsValid)
     {
         db.Entry(model).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(model));
 }
コード例 #5
0
 public ActionResult Edit(Country country)
 {
     if (ModelState.IsValid)
     {
         db.Entry(country).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(country));
 }
コード例 #6
0
 public ActionResult Edit(Warrant warrant)
 {
     warrant.division    = db.Divisions.Find(warrant.divisionID);
     warrant.Respondents = db.Respondents.Where(r => r.tipstaffRecordID == warrant.tipstaffRecordID).ToList();
     if (ModelState.IsValid)
     {
         db.Entry(warrant).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Details", "Warrant", new { id = warrant.tipstaffRecordID }));
     }
     ViewBag.protectiveMarkings = new SelectList(db.ProtectiveMarkings.Where(x => x.active == true), "protectiveMarkingID", "Detail", warrant.protectiveMarkingID);
     ViewBag.divisions          = new SelectList(db.Divisions.Where(x => x.active == true), "divisionID", "Detail", warrant.divisionID);
     ViewBag.caseStatusID       = new SelectList(db.CaseStatuses.Where(x => x.active == true), "caseStatusID", "Detail", warrant.caseStatusID);
     return(View(warrant));
 }
コード例 #7
0
        public ActionResult Create(TemplateEdit model)
        {
            var xml = string.Empty;

            try
            {
                //Tests before uploading
                if (model.uploadFile != null)
                {
                    if (!Path.GetExtension(model.uploadFile.FileName.ToLower()).EndsWith("xml"))
                    {
                        throw new NotUploaded("Please select an XML file to upload");
                    }
                    if (model.uploadFile.ContentLength == 0)
                    {
                        throw new NotUploaded("The selected file appears to be empty, please select a different file and re-try");
                    }
                    //Upload
                    var fileName = Path.Combine("C:\\TipstaffUploads", Path.GetFileName(model.uploadFile.FileName));
                    model.uploadFile.SaveAs(fileName); //Save to uploads folder
                    XmlDocument document = new XmlDocument();
                    document.Load(fileName);
                    xml = document.InnerXml;
                    //Delete file
                    System.IO.File.Delete(fileName);
                    model.Template.templateXML     = xml;
                    model.Template.active          = true;
                    db.Entry(model.Template).State = EntityState.Added;
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                else
                {
                    model.ErrorMessage     = "Please select a template file";
                    model.UploadSuccessful = false;
                    ModelState.AddModelError("Error", "Please select a template file");
                    return(View(model));
                }
            }
            catch (Exception ex)
            {
                model.ErrorMessage     = genericFunctions.GetLowestError(ex);
                model.UploadSuccessful = false;
                return(View(model));
            }
        }
 public ActionResult Edit(SolicitorFirmByTipstaffRecordViewModel model)
 {
     if (ModelState.IsValid)
     {
         db.Entry(model.SolicitorFirm).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Details", "SolicitorFirm", new { solicitorFirmID = model.solicitorFirmID, tipstaffRecordID = model.tipstaffRecordID }));
     }
     return(View(model));
 }
コード例 #9
0
 public ActionResult Edit(ApplicantEditModel model)
 {
     if (ModelState.IsValid)
     {
         db.Entry(model.applicant).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Details", "ChildAbduction", new { id = model.applicant.tipstaffRecordID }));
     }
     return(View(model));
 }
コード例 #10
0
 public ActionResult Edit(Address address)
 {
     if (ModelState.IsValid)
     {
         db.Entry(address).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Details", genericFunctions.TypeOfTipstaffRecord(address.tipstaffRecordID), new { id = address.tipstaffRecordID }));
     }
     return(View(address));
 }
コード例 #11
0
 public ActionResult Edit(PassportUploadModel model)
 {
     if (ModelState.IsValid)
     {
         db.Entry(model.passport).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Details", genericFunctions.TypeOfTipstaffRecord(model.passport.tipstaffRecordID), new { id = model.passport.tipstaffRecordID }));
     }
     return(View(model));
 }
コード例 #12
0
 public ActionResult Edit(EditSolicitorbyTipstaffRecordViewModel model)
 {
     if (ModelState.IsValid)
     {
         db.Entry(model.Solicitor).State = EntityState.Modified;
         db.SaveChanges();
         string controller = genericFunctions.TypeOfTipstaffRecord(model.TipstaffRecord);
         return(RedirectToAction("Details", "Solicitor", new { solicitorID = model.solicitorID, tipstaffRecordID = model.tipstaffRecordID }));
     }
     return(View(model));
 }
コード例 #13
0
        public ActionResult Create(RespondentCreationModel model, string submitButton)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            try
            {
                TipstaffRecord tr = db.TipstaffRecord.Find(model.tipstaffRecordID);
                //if (genericFunctions.TypeOfTipstaffRecord(tr) == "Warrant")
                if (tr is Warrant)
                {
                    Warrant w = (Warrant)tr;
                    w.RespondentName = model.respondent.PoliceDisplayName;
                    w.Respondents.Add(model.respondent);
                    db.Entry(w).State = EntityState.Modified;
                    db.SaveChanges();
                }
                else
                {
                    tr.Respondents.Add(model.respondent);
                }
                db.SaveChanges();
                if (Request.IsAjaxRequest())
                {
                    string url = string.Format("window.location='{0}';", Url.Action("Details", genericFunctions.TypeOfTipstaffRecord(tr), new { id = model.tipstaffRecordID }));
                    return(JavaScript(url));
                }
                else
                {
                    switch (submitButton)
                    {
                    case "Save,add new Respondent":
                        return(RedirectToAction("Create", "Respondent", new { id = model.tipstaffRecordID, initial = model.initial }));

                    case null:
                    default:
                        return(RedirectToAction("Details", genericFunctions.TypeOfTipstaffRecord(tr), new { id = model.tipstaffRecordID }));
                    }
                }
            }
            catch (DbUpdateException ex)
            {
                _logger.LogError(ex, $"DbUpdateException in RespondentController in Create method, for user {((CPrincipal)User).UserID}");

                if (Request.IsAjaxRequest())
                {
                    return(PartialView("_createRespondentForRecord", model));
                }
                else
                {
                    return(View(model));
                }
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, $"Exception in RespondentController in Create method, for user {((CPrincipal)User).UserID}");

                ErrorModel errModel = new ErrorModel(2);
                errModel.ErrorMessage  = genericFunctions.GetLowestError(ex);
                TempData["ErrorModel"] = errModel;
                return(RedirectToAction("IndexByModel", "Error", errModel ?? null));
            }
        }
コード例 #14
0
 public ActionResult Edit(ChildAbduction childabduction)
 {
     if (ModelState.IsValid)
     {
         db.Entry(childabduction).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Details", "ChildAbduction", new { id = childabduction.tipstaffRecordID }));
     }
     ViewBag.protectiveMarkingID = new SelectList(db.ProtectiveMarkings.Where(x => x.active == true), "protectiveMarkingID", "Detail", childabduction.protectiveMarkingID);
     ViewBag.caseStatusID        = new SelectList(db.CaseStatuses.Where(x => x.active == true), "caseStatusID", "Detail", childabduction.caseStatusID);
     ViewBag.caOrderTypeID       = new SelectList(db.CAOrderTypes.Where(x => x.active == true), "caOrderTypeID", "Detail", childabduction.caOrderTypeID);
     return(View(childabduction));
 }