Ejemplo n.º 1
0
        public ActionResult OsobaPridat(string jmeno, string prijmeni, string narozeni, string titulPred, string titulPo, int typOsoby)
        {
            var auth = Framework.ApiAuth.IsApiAuth(this, "TeamMember");

            if (auth.Authentificated)
            {
                DateTime?nar = ParseTools.ToDateTimeFromCode(narozeni);
                if (nar.HasValue == false)
                {
                    return(Content(Newtonsoft.Json.JsonConvert.SerializeObject(new { valid = false, error = "Invalid date format. Use yyyy-MM-dd format." }), "application/json"));
                }
                if (typOsoby < 0 || typOsoby > 3)
                {
                    return(Content(Newtonsoft.Json.JsonConvert.SerializeObject(new { valid = false, error = "Invalid typOsoby. Use 0 = NeniPolitik , 1 = ByvalyPolitik , 2 = VazbyNaPolitiky , 3 = Politik." })));
                }

                var no = Osoba.GetOrCreateNew(titulPred, jmeno, prijmeni, titulPo, nar, (Osoba.StatusOsobyEnum)typOsoby, auth.ApiCall.User);
                no.Vazby(true);

                return(Content(Newtonsoft.Json.JsonConvert.SerializeObject(
                                   new { valid = true, nameId = no.NameId })
                               , "application/json"));
            }
            else
            {
                return(View("Error401"));
            }
        }
Ejemplo n.º 2
0
        public ActionResult OsobaPridatSenatMandat(string nameId, string strana, string odDatum, string doDatum, string zdroj)
        {
            var auth = Framework.ApiAuth.IsApiAuth(this, "TeamMember");

            if (auth.Authentificated)
            {
                DateTime?dOd = ParseTools.ToDateTimeFromCode(odDatum);
                DateTime?dDo = ParseTools.ToDateTimeFromCode(doDatum);
                if (dOd.HasValue == false)
                {
                    return(Content(Newtonsoft.Json.JsonConvert.SerializeObject(new { valid = false, error = "Invalid date format odDatum. Use yyyy-MM-dd format." }), "application/json"));
                }
                //if (dDo.HasValue == false)
                //    return Content(Newtonsoft.Json.JsonConvert.SerializeObject(new { valid = false, error = "Invalid date format DoDatum. Use yyyy-MM-dd format." }), "application/json");

                return(AddEvent(auth, nameId, OsobaEvent.Types.Senator, "", "", strana, null, dOd, dDo, zdroj));
            }
            else
            {
                return(View("Error401"));
            }
        }