Example #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));
     }
 }
Example #2
0
        public ActionResult Create([Bind(Include = "Id, Debt, Employee, IsActive, Notes")] Warrant warrant)
        {
            Db db = new Db(DbServices.ConnectionString);

            if (ModelState.IsValid)
            {
                try
                {
                    WarrantServices.Insert(CurrentUser.Id, warrant, db);
                    TempData["Success"] = ResourceServices.GetString(Cf.Data.Resources.ResourceBase.Culture, "UI", "InsertConfirmed");
                    return(RedirectToAction("Index"));
                }
                catch (CfException cfex)
                {
                    TempData["Failure"] = cfex.ErrorDefinition.LocalizedMessage;
                }
                catch (Exception ex)
                {
                    TempData["Failure"] = ex.Message;
                }
            }

            ViewBag.DebtList     = new SelectList(DebtServices.List(db), "Id", "ReferenceNumber");
            ViewBag.EmployeeList = new SelectList(EmployeeServices.List(db), "Id", "FirstName");
            return(View(warrant));
        }
        public ActionResult Create(Warrant warrant)
        {
            if (warrant.DateCirculated == null)
            {
                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.resultID           = new SelectList(db.Results.Where(x => x.active == true), "resultID", "Detail", warrant.resultID);
                ViewBag.caseStatusID       = new SelectList(db.CaseStatuses.Where(x => x.active == true), "caseStatusID", "Detail", warrant.caseStatusID);
                ViewBag.noDateCirculated   = "Please enter the Date Circulated";
                return(View(warrant));
            }
            else
            {
                warrant.createdOn = DateTime.Now;
                if (ModelState.IsValid)
                {
                    db.Warrants.Add(warrant);
                    db.SaveChanges();
                    return(RedirectToAction("Create", "Respondent", 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.resultID           = new SelectList(db.Results.Where(x => x.active == true), "resultID", "Detail", warrant.resultID);
                ViewBag.caseStatusID       = new SelectList(db.CaseStatuses.Where(x => x.active == true), "caseStatusID", "Detail", warrant.caseStatusID);
                return(View(warrant));
            }
        }
Example #4
0
        public ActionResult DeleteConfirmed(int id)
        {
            Warrant warrant = db.Warrants.Find(id);

            db.Warrants.Remove(warrant);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #5
0
 public ActionResult Edit([Bind(Include = "ID,CriminalName,Crimes,FilingOfficer,Notes")] Warrant warrant)
 {
     if (ModelState.IsValid)
     {
         db.Entry(warrant).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(warrant));
 }
Example #6
0
        public ActionResult Create([Bind(Include = "ID,CriminalName,Crimes,FilingOfficer,Notes")] Warrant warrant)
        {
            if (ModelState.IsValid)
            {
                db.Warrants.Add(warrant);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(warrant));
        }
        //
        // GET: /Warrant/Edit/5
        public ActionResult Edit(int id)
        {
            Warrant warrant = db.Warrants.Find(id);

            if (warrant.caseStatus.sequence > 3)
            {
                TempData["UID"] = warrant.UniqueRecordID;
                return(RedirectToAction("ClosedFile", "Error"));
            }
            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));
        }
Example #8
0
        // GET: Warrants/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Warrant warrant = db.Warrants.Find(id);

            if (warrant == null)
            {
                return(HttpNotFound());
            }
            return(View(warrant));
        }
Example #9
0
        static void TestWarrant()
        {
            //#範例說明
            //#假設收盤價為20
            //#換股比率0.8, 每一仟股換發800股, 倒數為 1/0.8=1.25
            //#每股退2元
            //#履約價原為22元
            //#行使比例原為0.5

            //#調整後的履約價為24.75
            //#調整後的行使比例為0.444
            (double fs, double fk, double fn) = Warrant.Reduction(20, 1.25, 2, 22, 0.5);
            Console.WriteLine($"新參考價={fs}, 新履約價={fk}, 新行使比例={fn}");
        }
Example #10
0
        static void TestWarrant2()
        {
            //# 範例說明(3532台勝科)
            double s = 107.5;  //# 假設收盤價為107.5
            double a = 0.5;    //# 換股比率0.5
            double d = 5;      //# 每股退5元
            double k = 119.15; //# 履約價原為119.15元
            double n = 0.041;  //# 行使比例原為0.041

            //#調整後的履約價為24.75
            //#調整後的行使比例為0.444
            (double fs, double fk, double fn) = Warrant.ReductionEx(s, a, d, k, n);
            Console.WriteLine($"新參考價={fs}, 新履約價={fk}, 新行使比例={fn}");
        }
Example #11
0
        private static void Tank()
        {
            Soldier joe     = new Enlisted();
            Soldier pl      = new Officer();
            Soldier chief   = new Warrant();
            Weapon  tank    = new Tank();
            Units   platoon = new Platoon();

            Console.WriteLine($"A typical armor platoon consists of: {platoon.strength} Personnel");
            Console.WriteLine("All the enlisted men say " + joe.Describe());
            Console.WriteLine("While the officer says " + pl.Describe());
            Console.WriteLine("The maintenance chief says " + chief.Describe());
            Console.WriteLine("Soldiers use the " + tank.Name);
            Console.WriteLine("With a " + tank.Load());
        }
        //
        // GET: /Warrant/Create
        public ActionResult Create()
        {
            ViewBag.protectiveMarkings = new SelectList(db.ProtectiveMarkings.Where(x => x.active == true), "protectiveMarkingID", "Detail");
            ViewBag.divisions          = new SelectList(db.Divisions.Where(x => x.active == true), "divisionID", "Detail");
            ViewBag.resultID           = new SelectList(db.Results.Where(x => x.active == true), "resultID", "Detail");
            ViewBag.caseStatusID       = new SelectList(db.CaseStatuses.Where(x => x.active == true), "caseStatusID", "Detail");
            Warrant model = new Warrant();

            model.nextReviewDate = DateTime.Today.AddMonths(1);
            System.Security.Principal.IIdentity userIdentity = User.Identity;
            Tipstaff.CPrincipal thisUser = new CPrincipal(userIdentity);
            model.createdBy    = thisUser.User.DisplayName;
            model.caseStatusID = 1;
            return(View(model));
        }
 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));
 }
Example #14
0
        // GET: Warrant/Delete/5
        public ActionResult Delete(Nullable <int> id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Db      db      = new Db(DbServices.ConnectionString);
            Warrant warrant = WarrantServices.Get(id.Value, db);

            if (warrant == null)
            {
                return(HttpNotFound());
            }
            return(View(warrant));
        }
 public ActionResult Edit(RespondentCreationModel model)
 {
     if (ModelState.IsValid)
     {
         TipstaffRecord tr = db.TipstaffRecord.Find(model.tipstaffRecordID);
         if (tr is Warrant)
         {
             Warrant w = (Warrant)tr;
             w.RespondentName  = model.respondent.PoliceDisplayName;
             db.Entry(w).State = EntityState.Modified;
         }
         db.Entry(model.respondent).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Details", genericFunctions.TypeOfTipstaffRecord(model.respondent.tipstaffRecordID), new { id = model.respondent.tipstaffRecordID }));
     }
     return(View(model));
 }
Example #16
0
        // GET: Warrant/Edit/5
        public ActionResult Edit(Nullable <int> id)
        {
            Db db = new Db(DbServices.ConnectionString);

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Warrant warrant = WarrantServices.Get(id.Value, db);

            if (warrant == null)
            {
                return(HttpNotFound());
            }

            ViewBag.DebtList     = new SelectList(DebtServices.List(db), "Id", "ReferenceNumber", warrant.Debt);
            ViewBag.EmployeeList = new SelectList(EmployeeServices.List(db), "Id", "FirstName", warrant.Employee);
            return(View(warrant));
        }
Example #17
0
        public void Execute()
        {
            var dossier = Session.Query<Dossier>()
               .Where(d => d.InmateId == _inmateId)
               .SingleOrDefault();

            var warrant = new Warrant()
                              {
                                  Type = _warrantType,
                                  Duration = _duration,
                                  EffectiveFrom = _effectiveFrom,
                                  IssueAt = _issueAt,
                                  IssuerId = _issuerId,
                                  WarrantScan = _scanAttachmentId
                              };

            dossier.AddWarrant(warrant);

            Bus.Reply(new WarrantsReceived() { Warrants = new [] { warrant } });
        }
Example #18
0
        public void Execute()
        {
            var dossier = Session.Query <Dossier>()
                          .Where(d => d.InmateId == _inmateId)
                          .SingleOrDefault();

            var warrant = new Warrant()
            {
                Type          = _warrantType,
                Duration      = _duration,
                EffectiveFrom = _effectiveFrom,
                IssueAt       = _issueAt,
                IssuerId      = _issuerId,
                WarrantScan   = _scanAttachmentId
            };

            dossier.AddWarrant(warrant);

            Bus.Reply(new WarrantsReceived()
            {
                Warrants = new [] { warrant }
            });
        }
        public ActionResult CreateWarrant(WarrantVwViewModel model)
        {
            WarrantVwViewModel Model = new WarrantVwViewModel();

            try
            {
                EmployeeVw employee = EmployeeVwServices.Get(model.Instance.DebtEmployeeId);
                if (employee == null)
                {
                    TempData["Failure"] = "الرقم الذاتي غير صحيح";
                    Model.List          = WarrantVwServices.GetByDebtId(model.Instance.DebtId, db);
                    return(PartialView("_WarrantsList", Model));
                }
                // check if this employee is not the debt employee
                Debt d = DebtServices.Get(model.Instance.DebtId, db);
                if (d != null)
                {
                    if (d.Employee == model.Instance.DebtEmployeeId)
                    {
                        TempData["Failure"] = "لا يمكن أن يكفل الموظف نفسه";
                        Model.List          = WarrantVwServices.GetByDebtId(model.Instance.DebtId, db);
                        return(PartialView("_WarrantsList", Model));
                    }
                }


                // check if this employee has been added as a garantaur
                Warrant ewarrant = WarrantServices.GetByDebt_EmployeeFirstOrNull(model.Instance.DebtId, model.Instance.DebtEmployeeId);
                if (ewarrant != null)
                {
                    TempData["Failure"] = "هذا الموظف هو كفيل حالياً لهذه المديونية";
                }
                else
                {
                    Warrant w = new Warrant()
                    {
                        Debt     = model.Instance.DebtId,
                        Employee = model.Instance.DebtEmployeeId,
                        IsActive = model.Instance.IsActive,
                        Notes    = model.Instance.Notes
                    };
                    w = WarrantServices.Insert(CurrentUserId, w, db);
                }

                Model.List = WarrantVwServices.GetByDebtId(model.Instance.DebtId, db);

                return(PartialView("_WarrantsList", Model));
            }
            catch (CfException cfex)
            {
                TempData["Failure"] = cfex.ErrorDefinition.LocalizedMessage;
                //return Json(new { status = false, message = cfex.ErrorDefinition.LocalizedMessage }, JsonRequestBehavior.AllowGet);
            }
            catch (Exception ex)
            {
                TempData["Failure"] = ex.Message;
                //return Json(new { status = false, message = ex.Message }, JsonRequestBehavior.AllowGet);
            }
            Model.List = WarrantVwServices.GetByDebtId(model.Instance.DebtId, db);
            return(PartialView("_WarrantsList", Model));
        }
Example #20
0
 public void AddWarrant(Warrant warrant)
 {
     warrant.LocalId = ++LastWarrantId;
     Warrants.Add(warrant);
 }
        //
        // GET: /Warrant/Details/5
        public ViewResult Details(int id)
        {
            Warrant warrant = db.Warrants.Find(id);

            return(View(warrant));
        }
Example #22
0
        public static List <SearchResultRow> getMatches(string Name)
        {
            TipstaffDB db        = myDBContextHelper.CurrentContext;
            string     lowerName = Name.ToLower();

            try
            {
                List <SearchResultRow> Results = new List <SearchResultRow>();
                var kids = db.Children.Where(f => f.nameFirst.ToLower().Contains(lowerName) || f.nameMiddle.ToLower().Contains(lowerName) || f.nameLast.ToLower().Contains(lowerName));
                if (kids != null)
                {
                    foreach (Child child in kids)
                    {
                        string uniqID = "";
                        using (TipstaffDB tempDB = new TipstaffDB())
                        {
                            TipstaffRecord TR = tempDB.TipstaffRecord.Find(child.tipstaffRecordID);
                            uniqID = TR.UniqueRecordID;
                        };
                        Results.Add(new SearchResultRow
                        {
                            name                   = child.fullname,
                            partyID                = child.childID,
                            tipstaffRecordID       = child.tipstaffRecordID,
                            DateOfBirth            = child.dateOfBirth,
                            PartyType              = "Child",
                            tipstaffRecordType     = "ChildAbduction",
                            tipstaffUniqueRecordID = uniqID
                        });
                    }
                }
                var Resps = db.Respondents.Where(f => f.nameFirst.ToLower().Contains(lowerName) || f.nameMiddle.ToLower().Contains(lowerName) || f.nameLast.ToLower().Contains(lowerName));
                System.Diagnostics.Debug.Print(Resps.Count().ToString());
                if (Resps != null)
                {
                    foreach (Respondent resp in Resps)
                    {
                        string typePart2 = "";
                        string uniqID    = "";
                        using (TipstaffDB tempDB = new TipstaffDB())
                        {
                            if (genericFunctions.TypeOfTipstaffRecord(resp.tipstaffRecordID) == "Warrant")
                            {
                                Warrant temp = tempDB.Warrants.Find(resp.tipstaffRecordID);
                                typePart2 = string.Format(" ({0})", temp.division.Detail);
                            }
                            TipstaffRecord TR = tempDB.TipstaffRecord.Find(resp.tipstaffRecordID);
                            uniqID = TR.UniqueRecordID;
                        };
                        Results.Add(new SearchResultRow
                        {
                            name               = resp.fullname,
                            partyID            = resp.respondentID,
                            tipstaffRecordID   = resp.tipstaffRecordID,
                            DateOfBirth        = resp.dateOfBirth,
                            PartyType          = "Respondent",
                            tipstaffRecordType = string.Format("{0}{1}", genericFunctions.TypeOfTipstaffRecord(resp.tipstaffRecordID)
                                                               , typePart2),
                            tipstaffUniqueRecordID = uniqID
                        });
                    }
                }
                return(Results);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Print(ex.Message);
                //return null;
                throw new NotUploaded(ex.Message);
            }
        }
Example #23
0
 public void SetWarrant(Warrant status)
 {
     Wanted = status;
 }
        private string mergeData(Template template, TipstaffRecord tipstaffRecord)
        {
            string result = template.templateXML;
            int    kids   = 1;

            //merge generic fields
            result = result.Replace("||DATE||", DateTime.Now.ToShortDateString());
            result = result.Replace("||TIME||", DateTime.Now.ToShortTimeString());
            result = result.Replace("||NOW||", DateTime.Now.ToString("dd/MM/yy @ HH:mm"));
            result = result.Replace("||UNIQUERECORDID||", tipstaffRecord.UniqueRecordID);
            result = result.Replace("||USERNAME||", User.Identity.Name);

            if (tipstaffRecord.NPO == null)
            {
                result = result.Replace("||NPOREFERENCE||", "");
            }
            else
            {
                result = result.Replace("||NPOREFERENCE||", tipstaffRecord.NPO.Replace("&", "&#038;"));
            }
            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);
                }
            }
            else
            {
                result = result.Replace("||POSSIBLEADDRESSES||", "");
            }
            if (tipstaffRecord.Respondents != null)
            {
                string respNames = "";
                foreach (Respondent r in tipstaffRecord.Respondents)
                {
                    respNames += r.PoliceDisplayName + " | ";
                }
                if (respNames == "")
                {
                    result = result.Replace("||RESPONDENTSNAME||", "<<Please enter respondent's name");
                }
                else
                {
                    respNames = respNames.Substring(0, respNames.Length - 2);
                    result    = result.Replace("||RESPONDENTSNAME||", respNames);
                }
            }
            else
            {
                result = result.Replace("||RESPONDENTSNAME||", "<<Please enter respondent's name");
            }

            foreach (Address addr in tipstaffRecord.addresses)
            {
                result = result.Replace("||ADDRESSES||", SecurityElement.Escape(addr.PrintAddressSingleLine) + "<w:br/>||ADDRESSES||");
                result = result.Replace("||ADDRESSBLOCK||", addr.xmlBlock + "||ADDRESSBLOCK||");
            }
            result = result.Replace("||ADDRESSES||", "");
            result = result.Replace("||ADDRESSBLOCK||", "");

            if (genericFunctions.TypeOfTipstaffRecord(tipstaffRecord) == "ChildAbduction" && template.Discriminator == "ChildAbduction")
            {
                ChildAbduction ca         = (ChildAbduction)tipstaffRecord;
                PropertyInfo[] properties = typeof(ChildAbduction).GetProperties();

                foreach (PropertyInfo property in properties)
                {
                    var    propValue = "";
                    object value     = property.GetValue(ca, null);
                    if (value != null)
                    {
                        Type type = value.GetType();
                        if (type == typeof(string) || type == typeof(int))
                        {
                            propValue = value.ToString();
                        }
                        else if (type == typeof(DateTime))
                        {
                            propValue = ((DateTime)value).ToShortDateString();
                        }
                        else if (type == typeof(object))
                        {
                            //loop through properties of sub object
                            System.Diagnostics.Debug.Print(propValue.ToString());
                        }
                    }
                    result = result.Replace(string.Format("||{0}||", property.Name.ToUpper()), SecurityElement.Escape(propValue));
                }
                //child blocks
                foreach (Child child in ca.children)
                {
                    result = result.Replace("||CHILDBLOCK||", child.xmlBlock.Replace("||CHILDNUMBER||", kids.ToString()) + "||CHILDBLOCK||");
                    kids++;
                }
                result = result.Replace("||MULTICHILD||", ca.children.Count() > 1 ? "children" : "child");
                result = result.Replace("||CHILDBLOCK||", "");
                result = result.Replace("||CHILDNUMBER||", "");
                //respondent block
                foreach (Respondent resp in tipstaffRecord.Respondents)
                {
                    result = result.Replace("||RESPONDENTBLOCK||", resp.xmlBlock + "||RESPONDENTBLOCK||");
                }
                result = result.Replace("||RESPONDENTBLOCK||", "");
                result = result.Replace("||MULTIRESP||", ca.Respondents.Count() > 1?"people":"person");
                string pncids = "";
                foreach (Respondent r in ca.Respondents)
                {
                    if (r.PNCID != null && r.PNCID != "")
                    {
                        pncids += "(Respondent) " + r.PoliceDisplayName + " &#8211; " + r.PNCID + " &#8211; " + r.DateofBirthDisplay + " <w:br/>";
                    }
                }
                foreach (Child c in ca.children)
                {
                    if (c.PNCID != null && c.PNCID != "")
                    {
                        pncids += "(Child) " + c.PoliceDisplayName + " &#8211; " + c.PNCID + " &#8211; " + c.DateofBirthDisplay + " <w:br/>";
                    }
                }
                if (pncids == "")
                {
                    result = result.Replace("||PNCIDS||", "");
                }
                else
                {
                    result = result.Replace("||PNCIDS||", pncids);
                }
            }
            else if (template.Discriminator == "Warrant")
            {
                Warrant warrant = tipstaffRecord as Warrant;
                //result = result.Replace("||DIVISION||", warrant.division.Detail);
                PropertyInfo[] properties = typeof(Warrant).GetProperties();
                foreach (PropertyInfo property in properties)
                {
                    var    propValue = "";
                    object value     = property.GetValue(warrant, null);
                    if (value != null)
                    {
                        Type type = value.GetType();
                        if (type == typeof(string) || type == typeof(int))
                        {
                            propValue = value.ToString();
                        }
                        else if (type == typeof(DateTime))
                        {
                            propValue = ((DateTime)value).ToShortDateString();
                        }
                        else if (type == typeof(object))
                        {
                            //loop through properties of sub object
                            System.Diagnostics.Debug.Print(propValue.ToString());
                        }
                    }
                    result = result.Replace(string.Format("||{0}||", property.Name.ToUpper()), SecurityElement.Escape(propValue));
                }
                if (warrant.Respondents.Count() == 1)
                {
                    PropertyInfo[] respProp = typeof(Respondent).GetProperties();
                    foreach (PropertyInfo property in respProp)
                    {
                        var    propValue = "";
                        object value     = property.GetValue(warrant.Respondents.FirstOrDefault(), null);
                        if (value != null)
                        {
                            Type type = value.GetType();
                            if (type == typeof(string) || type == typeof(int))
                            {
                                propValue = value.ToString();
                            }
                            else if (type == typeof(DateTime))
                            {
                                propValue = ((DateTime)value).ToShortDateString();
                            }
                            else if (type == typeof(object))
                            {
                                //loop through properties of sub object
                                System.Diagnostics.Debug.Print(propValue.ToString());
                            }
                        }
                        result = result.Replace(string.Format("||{0}||", property.Name.ToUpper()), SecurityElement.Escape(propValue));
                    }
                    result = result.Replace("||GENDER.DETAIL||", warrant.Respondents.FirstOrDefault().gender.detail);
                    result = result.Replace("||NATIONALITY.DETAIL||", warrant.Respondents.FirstOrDefault().nationality.Detail);
                    result = result.Replace("||COUNTRY.DETAIL||", warrant.Respondents.FirstOrDefault().country.Detail);
                    result = result.Replace("||SKINCOLOUR.DETAIL||", warrant.Respondents.FirstOrDefault().SkinColour.Detail);
                    string pncids = "";
                    if (warrant.Respondents.FirstOrDefault().PNCID != null && warrant.Respondents.FirstOrDefault().PNCID != "")
                    {
                        pncids += warrant.Respondents.FirstOrDefault().PNCID + "<w:br/>";
                    }
                    if (pncids == "")
                    {
                        result = result.Replace("||PNCID||", "");
                    }
                    else
                    {
                        result = result.Replace("||PNCID||", pncids);
                    }
                }
            }
            return(result);
        }
        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));
            }
        }