public ActionResult Organisations(string q, int?t) { if (!t.HasValue) { return(Json("", JsonRequestBehavior.AllowGet)); } List <string> result = new List <string>(); //if (string.IsNullOrEmpty(q) || q.Length <2) // return Json(result, JsonRequestBehavior.AllowGet); result = OsobaEvent.GetOrganisations(q, t, 200).ToList(); if (!string.IsNullOrEmpty(Request.Headers["Origin"])) { if (Request.Headers["Origin"].Contains(".hlidacstatu.cz") //|| Request.Headers["Origin"].Contains(".hlidacstatu.cz") ) { Response.AddHeader("Access-Control-Allow-Origin", Request.Headers["Origin"]); } } return(Json(result, JsonRequestBehavior.AllowGet)); }
public JsonResult UpdateEvent(OsobaEvent osobaEvent) { if (ModelState.IsValid) { var result = OsobaEvent.CreateOrUpdate(osobaEvent, this.User.Identity.Name); return(Json(new { Success = true })); } var errorModel = GetModelErrorsJSON(); Response.StatusCode = 400; return(new JsonResult() { Data = errorModel }); }
public JsonResult DeleteEvent(int?id) { if ((id ?? 0) == 0) { Response.StatusCode = 400; return(new JsonResult() { Data = "chybí id" }); } OsobaEvent osobaEvent = OsobaEvent.GetById(id ?? 0); osobaEvent.Delete(this.User.Identity.Name); return(Json(new { Success = true })); }
public List <FirmaSocialDTO> Social([FromUri] OsobaEvent.SocialNetwork[] typ) { var socials = (typ is null || typ.Length == 0) ? Enum.GetNames(typeof(OsobaEvent.SocialNetwork)) : typ.Select(t => t.ToString("G")); Expression <Func <OsobaEvent, bool> > socialNetworkFilter = e => e.Type == (int)OsobaEvent.Types.SocialniSite && e.Ico.Length == 8 && socials.Contains(e.Organizace); var events = OsobaEvent.GetByEvent(socialNetworkFilter) .GroupBy(e => e.Ico) .Select(g => TransformEventsToFirmaSocial(g)) .Where(r => r != null) .ToList(); return(events); }
private ActionResult AddEvent(Framework.ApiAuth.Result auth, string nameId, OsobaEvent.Types type, string title, string description, string addInfo, decimal?addInfoNum, DateTime?odDatum, DateTime?doDatum, string zdroj) { Osoba o = Osoba.GetByNameId(nameId); if (o == null) { return(Content(Newtonsoft.Json.JsonConvert.SerializeObject(new { valid = false, error = "Invalid nameId. Osoba not found" }), "application/json")); } OsobaEvent oe = new OsobaEvent(o.InternalId, title, description, type); oe.AddInfo = addInfo; oe.AddInfoNum = addInfoNum; oe.DatumOd = odDatum; oe.DatumDo = doDatum; oe.Zdroj = zdroj; o.AddOrUpdateEvent(oe, auth.ApiCall.User); return(Content(Newtonsoft.Json.JsonConvert.SerializeObject( new { valid = true }), "application/json")); }
/// <summary> /// Uploads new donations to OsobaEvent table /// </summary> /// <param name="donations"></param> public static void UploadPeopleDonations(Donations donations) { foreach (var personDonations in donations.GetDonations()) { var donor = personDonations.Key; Osoba osoba = Osoba.GetOrCreateNew(donor.TitleBefore, donor.Name, donor.Surname, donor.TitleAfter, donor.DateOfBirth, Osoba.StatusOsobyEnum.Sponzor, _user); var osobaEvents = osoba.NoFilteredEvents(ev => ev.Type == (int)OsobaEvent.Types.Sponzor).ToList(); foreach (var donation in personDonations.Value) { var eventToRemove = osobaEvents.Where(oe => oe.AddInfoNum == donation.Amount && oe.AddInfo == donation.ICO && oe.DatumOd.HasValue && oe.DatumOd.Value.Year == donation.Date.Year).FirstOrDefault(); if (eventToRemove is null) { // add event var newEvent = new OsobaEvent() { Organizace = NormalizePartyName(donation.Party, donation.ICO), DatumOd = donation.Date, AddInfoNum = donation.Amount, AddInfo = donation.ICO, Zdroj = _zdroj, Note = donation.Description, Type = (int)OsobaEvent.Types.Sponzor }; osoba.AddOrUpdateEvent(newEvent, _user, checkDuplicates: false); } else { osobaEvents.Remove(eventToRemove); } } } }
public ActionResult AddPersons(FormCollection form) { this.Server.ScriptTimeout = 600; List <string> newIds = new List <string>(); string tabdelimited = form["data"]; foreach (var line in tabdelimited.Split(new string[] { "\n", "\r" }, StringSplitOptions.RemoveEmptyEntries)) { string[] cols = line.Split(new string[] { "\t", "|" }, StringSplitOptions.None); // Vždy musí být řádek o 13 sloupcích. Povinné položky jsou: // varianta a) jmeno, prijmeni, narozeni // varianta b) fullname, narozeni if (cols.Count() != 13) { continue; } string fullName = cols[0]; string jmeno = cols[1]; string prijmeni = cols[2]; string titulPred = cols[3]; string titulPo = cols[4]; DateTime?narozeni = Devmasters.DT.Util.ToDate(cols[5]); Osoba.StatusOsobyEnum status = GetStatusFromText(cols[6]); string clenstviStrana = ParseTools.NormalizaceStranaShortName(cols[7]); DateTime?clenstviVznik = Devmasters.DT.Util.ToDate(cols[8]); string eventOrganizace = cols[9]; string eventRole = cols[10]; DateTime?eventVznik = Devmasters.DT.Util.ToDate(cols[11]); string eventTyp = cols[12]; // set person from fulltext when not properly defined if (string.IsNullOrWhiteSpace(jmeno) || string.IsNullOrWhiteSpace(prijmeni)) { if (string.IsNullOrWhiteSpace(fullName)) { continue; } var osoba = Lib.Validators.JmenoInText(fullName); if (osoba is null) { continue; } if (string.IsNullOrWhiteSpace(jmeno)) { jmeno = osoba.Jmeno; } if (string.IsNullOrWhiteSpace(prijmeni)) { prijmeni = osoba.Prijmeni; } if (string.IsNullOrWhiteSpace(titulPred)) { titulPred = osoba.TitulPred; } if (string.IsNullOrWhiteSpace(titulPo)) { titulPo = osoba.TitulPo; } } // when there is no narozeni Date, then we are not going to save person... if (!narozeni.HasValue) { continue; } Osoba p = Osoba.GetOrCreateNew(titulPred, jmeno, prijmeni, titulPo, narozeni, status, this.User.Identity.Name); if (!string.IsNullOrWhiteSpace(clenstviStrana)) { OsobaEvent clenStrany = new OsobaEvent { OsobaId = p.InternalId, DatumOd = clenstviVznik, Type = 7, AddInfo = "člen strany", Organizace = clenstviStrana, Title = $"člen v {clenstviStrana}" }; OsobaEvent.CreateOrUpdate(clenStrany, this.User.Identity.Name); } if (int.TryParse(eventTyp, out int typ) && !string.IsNullOrWhiteSpace(eventRole) && !string.IsNullOrWhiteSpace(eventOrganizace)) { OsobaEvent dalsiEvent = new OsobaEvent { OsobaId = p.InternalId, DatumOd = eventVznik, Type = typ, AddInfo = eventRole, Organizace = eventOrganizace, Title = $"{eventRole} v {eventOrganizace}" }; OsobaEvent.CreateOrUpdate(dalsiEvent, this.User.Identity.Name); } //Guid? foundId; //if (Osoba.Searching.GetByName(p.Jmeno, p.Prijmeni, p.Narozeni.Value) == null) //{ // if (cols.Count() > 5) // p.Description = cols[5]; // if (cols.Count() > 6) // p.PersonStatus = string.IsNullOrEmpty(cols[6]) ? 0 : int.Parse(cols[6]); // if (cols.Count() > 7) // p.Zdroj = cols[7]; // if (cols.Count() > 8) // p.MoreInfoUrl = cols[8]; // var res = Person.Import(p, true); // if (res.IsValid) // newIds.Add(res.Id + " " + p.FullName()); //} } return(View(newIds)); }
public SocialNetworkDTO(OsobaEvent osobaEvent) { this.Id = osobaEvent.AddInfo; this.Type = osobaEvent.Organizace; }