public ActionResult Create(Sponsor incomingsponsor) { try { string sponsorasstring = JsonConvert.SerializeObject(incomingsponsor); if (UniversalFunctions.ContainsSpecialChar(sponsorasstring)) { ModelState.AddModelError("Cannot contain semi-colons", "Cannot contain semi-colons"); } ModelState.Remove("Contract.RegistrationDate"); ModelState.Remove("Contract.ExpirationDate"); ModelState.Remove("Sponsorship.Date"); if (ModelState.IsValid) { incomingsponsor._id = Guid.NewGuid().ToString(); incomingsponsor.Contract.RegistrationDate = incomingsponsor.Contract.RegistrationDate.AddHours(5); incomingsponsor.Contract.ExpirationDate = incomingsponsor.Contract.ExpirationDate.AddHours(5); sponsorManager.AddSponsorToDB(incomingsponsor); return(RedirectToAction("Index")); } else { ViewBag.containsspecialchar = UniversalFunctions.ContainsSpecialChar(sponsorasstring); return(View()); } } catch { return(RedirectToAction("Localserver", "Home")); } }
public ActionResult Create(Event incomingevent) { try { string eventasstring = JsonConvert.SerializeObject(incomingevent); if (UniversalFunctions.ContainsSpecialChar(eventasstring)) { ModelState.AddModelError("Cannot contain semi-colons", "Cannot contain semi-colons"); } ModelState.Remove("NumberOfVolunteersNeeded"); ModelState.Remove("DateOfEvent"); ModelState.Remove("Duration"); if (ModelState.IsValid) { incomingevent._id = Guid.NewGuid().ToString(); incomingevent.DateOfEvent = incomingevent.DateOfEvent.AddHours(5); eventManager.AddEventToDB(incomingevent); return(RedirectToAction("Index")); } else { ViewBag.containsspecialchar = UniversalFunctions.ContainsSpecialChar(eventasstring); return(View()); } } catch { return(RedirectToAction("Localserver", "Home")); } }
public ActionResult Create(Volunteer volunteer, IFormFile image) { try { if (UniversalFunctions.ContainsSpecialChar(JsonConvert.SerializeObject(volunteer))) { ModelState.AddModelError("Cannot contain semi-colons", "Cannot contain semi-colons"); } ModelState.Remove("Birthdate"); ModelState.Remove("HourCount"); ModelState.Remove("CIEliberat"); if (ModelState.IsValid) { volunteer._id = Guid.NewGuid().ToString(); volunteer.Birthdate = volunteer.Birthdate.AddHours(5); volunteer.Image = UniversalFunctions.Addimage(image); volunteerManager.AddVolunteerToDB(volunteer); return(RedirectToAction("Index")); } else { ViewBag.containsspecialchar = UniversalFunctions.ContainsSpecialChar(JsonConvert.SerializeObject(volunteer)); return(View()); } } catch { return(RedirectToAction("Localserver", "Home")); } }
public ActionResult Edit(string id, Beneficiary beneficiary, IFormFile image) { try { if (UniversalFunctions.ContainsSpecialChar(JsonConvert.SerializeObject(beneficiary))) { ModelState.AddModelError("Cannot contain semi-colons", "Cannot contain semi-colons"); } ModelState.Remove("Contract.RegistrationDate"); ModelState.Remove("Contract.ExpirationDate"); ModelState.Remove("Marca.IdAplication"); ModelState.Remove("CI.ExpirationDateCI"); ModelState.Remove("Marca.IdContract"); ModelState.Remove("Marca.IdInvestigation"); ModelState.Remove("NumberOfPortions"); ModelState.Remove("LastTimeActiv"); ModelState.Remove("Personalinfo.Birthdate"); ModelState.Remove("CI.ICExpirationDate"); if (ModelState.IsValid) { if (image != null) { beneficiary.Image = UniversalFunctions.Addimage(image); } else { Beneficiary b = beneficiaryManager.GetOneBeneficiary(id); beneficiary.Image = b.Image; } List <ModifiedIDs> modifiedidlist = modifiedDocumentManager.GetListOfModifications(); string modifiedids = JsonConvert.SerializeObject(modifiedidlist); if (!modifiedids.Contains(id)) { Beneficiary currentbeneficiary = beneficiaryManager.GetOneBeneficiary(id); string currentbenefasstring = JsonConvert.SerializeObject(currentbeneficiary); auxiliaryDBManager.AddDocumenttoDB(currentbenefasstring); } beneficiary.PersonalInfo.Birthdate = beneficiary.PersonalInfo.Birthdate.AddHours(5); beneficiaryManager.UpdateABeneficiary(beneficiary, id); return(RedirectToAction("Index")); } else { ViewBag.id = id; bool containsspecialchar = true; return(RedirectToAction("Edit", new { id, containsspecialchar })); } } catch { return(RedirectToAction("Localserver", "Home")); } }
public ActionResult Edit(string id, Volunteer volunteer, IFormFile image) { try { if (UniversalFunctions.ContainsSpecialChar(JsonConvert.SerializeObject(volunteer))) { ModelState.AddModelError("Cannot contain semi-colons", "Cannot contain semi-colons"); } ModelState.Remove("Birthdate"); ModelState.Remove("HourCount"); ModelState.Remove("CIEliberat"); if (ModelState.IsValid) { if (image != null) { volunteer.Image = UniversalFunctions.Addimage(image); } else { Volunteer v = volunteerManager.GetOneVolunteer(id); volunteer.Image = v.Image; } volunteer.Birthdate = volunteer.Birthdate.AddHours(5); List <ModifiedIDs> modifiedidlist = modifiedDocumentManager.GetListOfModifications(); string modifiedids = JsonConvert.SerializeObject(modifiedidlist); if (!modifiedids.Contains(id)) { Volunteer currentvol = volunteerManager.GetOneVolunteer(id); string currentvolasstring = JsonConvert.SerializeObject(currentvol); auxiliaryDBManager.AddDocumenttoDB(currentvolasstring); } volunteerManager.UpdateAVolunteer(volunteer, id); return(RedirectToAction("Index")); } else { ViewBag.id = id; bool containsspecialchar = true; return(RedirectToAction("Edit", new { id, containsspecialchar })); } } catch { return(RedirectToAction("Localserver", "Home")); } }
public ActionResult Edit(string id, Sponsor sponsor) { try { string sponsorasstring = JsonConvert.SerializeObject(sponsor); if (UniversalFunctions.ContainsSpecialChar(sponsorasstring)) { ModelState.AddModelError("Cannot contain semi-colons", "Cannot contain semi-colons"); } Sponsor currentsavedsponsor = sponsorManager.GetOneSponsor(id); ModelState.Remove("Contract.RegistrationDate"); ModelState.Remove("Contract.ExpirationDate"); ModelState.Remove("Sponsorship.Date"); if (ModelState.IsValid) { sponsor.Contract.RegistrationDate = sponsor.Contract.RegistrationDate.AddHours(5); sponsor.Contract.ExpirationDate = sponsor.Contract.ExpirationDate.AddHours(5); sponsor.Sponsorship.Date = sponsor.Sponsorship.Date.AddHours(5); List <ModifiedIDs> modifiedidlist = modifiedDocumentManager.GetListOfModifications(); string modifiedids = JsonConvert.SerializeObject(modifiedidlist); if (!modifiedids.Contains(id)) { Sponsor currentsponsor = sponsorManager.GetOneSponsor(id); string currentsponsorasstring = JsonConvert.SerializeObject(currentsponsor); auxiliaryDBManager.AddDocumenttoDB(currentsponsorasstring); } sponsorManager.UpdateSponsor(sponsor, id); return(RedirectToAction("Index")); } else { ViewBag.id = id; ViewBag.containsspecialchar = UniversalFunctions.ContainsSpecialChar(sponsorasstring); return(View()); } } catch { return(RedirectToAction("Localserver", "Home")); } }
public ActionResult Create(Beneficiary beneficiary, IFormFile image) { try { if (UniversalFunctions.ContainsSpecialChar(JsonConvert.SerializeObject(beneficiary))) { ModelState.AddModelError("Cannot contain semi-colons", "Cannot contain semi-colons"); } ModelState.Remove("CI.ExpirationDateCI"); ModelState.Remove("Contract.RegistrationDate"); ModelState.Remove("Contract.ExpirationDate"); ModelState.Remove("Marca.IdAplication"); ModelState.Remove("CI.CIEliberat"); ModelState.Remove("Marca.IdContract"); ModelState.Remove("Marca.IdInvestigation"); ModelState.Remove("NumberOfPortions"); ModelState.Remove("LastTimeActiv"); ModelState.Remove("Personalinfo.Birthdate"); ModelState.Remove("CI.ICExpirationDate"); if (ModelState.IsValid) { beneficiary._id = Guid.NewGuid().ToString(); beneficiary.PersonalInfo.Birthdate = beneficiary.PersonalInfo.Birthdate.AddHours(5); beneficiary.Image = UniversalFunctions.Addimage(image); beneficiaryManager.AddBeneficiaryToDB(beneficiary); return(RedirectToAction("Index")); } else { ViewBag.containsspecialchar = UniversalFunctions.ContainsSpecialChar(JsonConvert.SerializeObject(beneficiary)); return(View()); } } catch { return(RedirectToAction("Localserver", "Home")); } }
public ActionResult Edit(string id, Event incomingevent) { try { string eventasstring = JsonConvert.SerializeObject(incomingevent); if (UniversalFunctions.ContainsSpecialChar(eventasstring)) { ModelState.AddModelError("Cannot contain semi-colons", "Cannot contain semi-colons"); } ModelState.Remove("NumberOfVolunteersNeeded"); ModelState.Remove("DateOfEvent"); ModelState.Remove("Duration"); if (ModelState.IsValid) { incomingevent.DateOfEvent = incomingevent.DateOfEvent.AddHours(5); List <ModifiedIDs> modifiedidlist = modifiedDocumentManager.GetListOfModifications(); string modifiedids = JsonConvert.SerializeObject(modifiedidlist); if (!modifiedids.Contains(id)) { Event currentevent = eventManager.GetOneEvent(id); string currenteventasstring = JsonConvert.SerializeObject(currentevent); auxiliaryDBManager.AddDocumenttoDB(currenteventasstring); } eventManager.UpdateAnEvent(incomingevent, id); return(RedirectToAction("Index")); } else { ViewBag.id = id; ViewBag.containsspecialchar = UniversalFunctions.ContainsSpecialChar(eventasstring); return(View()); } } catch { return(RedirectToAction("Localserver", "Home")); } }