Example #1
0
        public ActionResult DeactivateConfirmed(int id)
        {
            Solicitor model = db.Solicitors.Find(id);

            model.active          = false;
            model.deactivated     = DateTime.Now;
            model.deactivatedBy   = User.Identity.Name;
            db.Entry(model).State = EntityState.Modified;
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #2
0
        // GET: /Admin/Solicitor/Details/5
        public ActionResult Details(int id)
        {
            Solicitor model = db.Solicitors.Find(id);

            if (model.active == false)
            {
                ErrorModel errModel = new ErrorModel(2);
                errModel.ErrorMessage  = string.Format("You cannot view {0} as it has been deactivated, please raise a help desk call to re-activate it.", model.solicitorName);
                TempData["ErrorModel"] = errModel;
                return(RedirectToAction("IndexByModel", "Error", new { area = "", model = errModel ?? null }));
            }
            return(View(model));
        }
Example #3
0
        // GET: /Admin/Solicitor/Delete/5
        public ActionResult Deactivate(int id)
        {
            Solicitor model = db.Solicitors.Find(id);

            if (model.active == false)
            {
                ErrorModel errModel = new ErrorModel(2);
                errModel.ErrorMessage  = string.Format("You cannot view {0} as it has been deactivated, please raise a help desk call to re-activate it.", model.solicitorName);
                TempData["ErrorModel"] = errModel;
                return(RedirectToAction("IndexByModel", "Error", new { area = "", model = errModel ?? null }));
            }
            if (model.TipstaffRecords.Count() > 0)
            {
                ErrorModel errModel = new ErrorModel(2);
                errModel.ErrorMessage  = string.Format("You cannot deactivate {0} as they are still linked to cases, please re-allocate all cases before deactivating it.", model.solicitorName);
                TempData["ErrorModel"] = errModel;
                return(RedirectToAction("IndexByModel", "Error", new { area = "", model = errModel ?? null }));
            }
            return(View(model));
        }
 public ActionResult CreateSolicitor(Solicitor solicitor, int warrantID)
 {
     if (ModelState.IsValid)
     {
         solicitor.active = true;
         db.Solicitors.Add(solicitor);
         db.SaveChanges();
         if (Request.IsAjaxRequest())
         {
             return(RedirectToAction("Create", "TipstaffRecordSolicitor", new { tipstaffRecord = warrantID, solicitor = solicitor.solicitorID }));
             //return View("_createSolicitorForWarrantSuccess", model);
         }
         else
         {
             return(RedirectToAction("Index", "Home"));
         }
     }
     ViewBag.salutationID    = new SelectList(db.Salutations.Where(x => x.active == true), "salutationID", "Detail");
     ViewBag.solicitorFirmID = new SelectList(db.SolicitorsFirms, "solicitorFirmID", "firmName", solicitor.solicitorFirmID);
     //return PartialView("_createSolicitor");
     return(PartialView("_createSolicitorForWarrant"));
 }
        private string mergeData(Template template, TipstaffRecord tipstaffRecord, Solicitor solicitor)
        {
            string result = mergeData(template, tipstaffRecord);

            if (tipstaffRecord.NPO == null)
            {
                result = result.Replace("||NPOREFERENCE||", "");
            }
            else
            {
                result = result.Replace("||NPOREFERENCE||", tipstaffRecord.NPO.Replace("&", "&"));
            }
            if (tipstaffRecord.addresses != null)
            {
                string addresses = "";
                foreach (Address a in tipstaffRecord.addresses)
                {
                    addresses += a.printAddressMultiLine + "<w:br/><w:br/>";
                }
                if (addresses == "")
                {
                    result = result.Replace("||POSSIBLEADDRESSES||", "");
                }
                else
                {
                    result = result.Replace("||POSSIBLEADDRESSES||", addresses);
                }
            }
            if (genericFunctions.TypeOfTipstaffRecord(tipstaffRecord) != "Warrant") //Check PNCIDs
            {
                string         pncids = "";
                ChildAbduction ca     = (ChildAbduction)tipstaffRecord;
                foreach (Child c in ca.children)
                {
                    if (c.PNCID != null && c.PNCID != "")
                    {
                        pncids += c.PNCID + "<w:br/>";
                    }
                }
                if (pncids == "")
                {
                    result = result.Replace("||PNCIDS||", "");
                }
                else
                {
                    result = result.Replace("||PNCIDS||", pncids);
                }
            }
            if (solicitor == null)
            {
                result = result.Replace("||ADDRESSEENAME||", "");
                result = result.Replace("||ADDRESS||", "Add Address here");
            }
            else
            {
                result = result.Replace("||ADDRESSEENAME||", solicitor.AddresseeName);
                if (solicitor.SolicitorFirm != null)
                {
                    result = result.Replace("||ADDRESS||", solicitor.SolicitorFirm.printAddressMultiLine);
                }
                else
                {
                    result = result.Replace("||ADDRESS||", "");
                }
            }
            return(result);
        }
        public ActionResult Create4(int tipstaffRecordID, int templateID, int solicitorID)
        {
            try
            {
                //get solicitor from solicitorID
                Solicitor solicitor = db.Solicitors.Find(solicitorID);

                //Get TipstaffRecord from warrantID
                TipstaffRecord tipstaffRecord = db.TipstaffRecord.Find(tipstaffRecordID);
                if (tipstaffRecord.caseStatus.sequence > 3)
                {
                    TempData["UID"] = tipstaffRecord.UniqueRecordID;
                    return(RedirectToAction("ClosedFile", "Error"));
                }

                //Get Template from templateID
                Template template = db.Templates.Find(templateID);
                if (template == null)
                {
                    throw new FileLoadException(string.Format("No database record found for template reference {0}", templateID));
                }

                //set fileOutput details
                WordFile fileOutput = new WordFile(tipstaffRecord, Server.MapPath("~/Documents/"), template);

                //Create XML object for Template
                XmlDocument xDoc = new XmlDocument();

                //Merge Data
                xDoc.InnerXml = mergeData(template, tipstaffRecord, solicitor);

                ////Save resulting document
                //xDoc.Save(fileOutput.fullName); //Save physical file
                //if (!System.IO.File.Exists(fileOutput.fullName)) throw new FileNotFoundException(string.Format("File {0} could not be created", fileOutput.fileName));

                //Create and add a Document to TipstaffRecord
                Document doc = new Document();
                doc.binaryFile        = genericFunctions.ConvertToBytes(xDoc);
                doc.mimeType          = "application/msword";
                doc.fileName          = fileOutput.fileName;
                doc.countryID         = 244; //UK!
                doc.nationalityID     = 27;  //English
                doc.documentTypeID    = 1;   //generated
                doc.documentStatusID  = 1;   //generated
                doc.documentReference = template.templateName;
                doc.templateID        = template.templateID;
                doc.createdOn         = DateTime.Now;
                doc.createdBy         = User.Identity.Name;
                tipstaffRecord.Documents.Add(doc);

                //Save Changes
                db.SaveChanges();

                //Return saved document
                //return File(fileOutput.fullName, "application/doc", fileOutput.fileName); // return physical file
                return(File(doc.binaryFile, doc.mimeType, doc.fileName)); //return byte version
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, $"Exception in TemplateController in Create4 method, for user {((CPrincipal)User).UserID}");

                ErrorModel model = new ErrorModel(2);
                model.ErrorMessage     = ex.Message;
                TempData["ErrorModel"] = model;
                return(RedirectToAction("IndexByModel", "Error", model ?? null));
                //Note: working redirect to view with Model
                //Note: Working error redirect
            }
        }
Example #7
0
 public async Task OnGetAsync(int id)
 {
     Solicitor = await _db.Solicitor.FindAsync(id);
 }