public ContentResult ClearTag() { var tag = CurrentDatabase.TagCurrent(); CurrentDatabase.ExecuteCommand("delete dbo.TagPerson where Id = {0}", tag.Id); return(Content("ok")); }
public ContentResult Edit(string id, string value) { try { var i = id.Substring(2).ToInt(); var m = new MeetingModel(i, CurrentDatabase); switch (id[0]) { case 'd': m.meeting.Description = value; break; case 'h': m.meeting.HeadCount = value.ToInt(); break; case 't': CurrentDatabase.ExecuteCommand(@" update dbo.Attend set MeetingDate = {0} where MeetingId = {1}; update dbo.Meetings set MeetingDate = {0} where MeetingId = {1}; ", value.ToDate(), m.meeting.MeetingId); break; } CurrentDatabase.SubmitChanges(); return(Content(value)); } catch (Exception ex) { return(Content("error: " + ex.Message)); } }
public ActionResult ContentDeleteDrafts(string[] draftID) { string deleteList = String.Join(",", draftID); CurrentDatabase.ExecuteCommand("DELETE FROM dbo.Content WHERE Id IN(" + deleteList + ")", ""); return(Redirect("/Display#tab_savedDrafts")); }
public ActionResult ContentDeleteDrafts(string[] draftID) { string deleteList = string.Join(",", draftID.Select(d => d.ToInt()));//Prevent potential SQL injection CurrentDatabase.ExecuteCommand($"DELETE FROM dbo.ContentKeywords WHERE Id IN({deleteList})"); CurrentDatabase.ExecuteCommand($"DELETE FROM dbo.Content WHERE Id IN({deleteList})", ""); return(Redirect("/Display#tab_savedDrafts")); }
public ActionResult Move(int fromid, int toid) { CurrentDatabase.ExecuteCommand("UPDATE dbo.OrganizationMembers SET MemberTypeId = {0} WHERE MemberTypeId = {1}", toid, fromid); CurrentDatabase.ExecuteCommand("UPDATE dbo.EnrollmentTransaction SET MemberTypeId = {0} WHERE MemberTypeId = {1}", toid, fromid); CurrentDatabase.ExecuteCommand("UPDATE dbo.Attend SET MemberTypeId = {0} WHERE MemberTypeId = {1}", toid, fromid); Util.TempSuccessMessage = "Member type and associated members were successfully migrated."; return(Redirect("/MemberType/")); }
public ActionResult DeleteManual(int id, TransactionsModel m) { CurrentDatabase.ExecuteCommand(@" UPDATE dbo.OrganizationMembers SET TranId = NULL WHERE TranId = {0} DELETE dbo.TransactionPeople WHERE Id = {0} DELETE dbo.[Transaction] WHERE Id = {0} ", id); return(View("List", m)); }
public ActionResult ContentDelete(int id) { var content = CurrentDatabase.ContentFromID(id); CurrentDatabase.ExecuteCommand("DELETE FROM dbo.ContentKeywords WHERE Id = {0}", id); CurrentDatabase.ExecuteCommand("DELETE FROM dbo.Content WHERE Id = {0}", id); var url = GetIndexTabUrl(content); return(Redirect(url)); }
internal void StartOver() { HistoryAdd("startover"); UpdateDatum(abandoned: true); CurrentDatabase.ExecuteCommand(@" UPDATE dbo.RegistrationData SET abandoned = 1 WHERE ISNULL(abandoned, 0) = 0 AND UserPeopleid = {0} AND OrganizationId = {1}", Datum.UserPeopleId, Datum.OrganizationId); }
public void ResetMoved() { var q = from om in CurrentDatabase.OrganizationMembers where om.Organization.DivOrgs.Any(di => di.DivId == SourceDivId) where om.Moved == true select om; CurrentDatabase.ExecuteCommand(@" UPDATE dbo.OrganizationMembers SET Moved = NULL WHERE EXISTS(SELECT NULL FROM dbo.DivOrg WHERE OrgId = OrganizationId AND DivId = {0})", SourceDivId); }
public ActionResult Delete(string id, string type) { try { var iid = id.Substring(1).ToInt(); CurrentDatabase.ExecuteCommand("delete lookup." + type + " where id = {0}", iid); return(new EmptyResult()); } catch (SqlException) { return(Json(new { error = $"Cannot delete {type} because it is in use" })); } }
public ActionResult Create(int?id, string type) { if (id.HasValue) { var q = CurrentDatabase.ExecuteQuery <Row>("select * from lookup." + type + " where id = {0}", id); if (!q.Any()) { CurrentDatabase.ExecuteCommand("insert lookup." + type + " (id, code, description) values ({0}, '', '')", id); } } return(Redirect($"/Lookup/{type}/#{id}")); }
public void DebugCleanUp() { var q = from om in CurrentDatabase.OrganizationMembers where new[] { 828612, Util.UserPeopleId }.Contains(om.PeopleId) where om.OrganizationId == Orgid select om; foreach (var om in q) { om.Drop(CurrentDatabase, CMSImageDataContext.Create(CurrentDatabase.Host), DateTime.Now); CurrentDatabase.ExecuteCommand("DELETE dbo.EnrollmentTransaction WHERE PeopleId = {0} AND OrganizationId = {1}", om.PeopleId, om.OrganizationId); } CurrentDatabase.SubmitChanges(); }
public ActionResult TransferGiving(int id) { if (!User.InAnyRole("Admin", "Finance")) { return(new HttpUnauthorizedResult()); } var person = CurrentDatabase.People.SingleOrDefault(p => p.PeopleId == id && p.DeceasedDate != null); if (person == null) { return(new HttpNotFoundResult()); } var count = CurrentDatabase.ExecuteCommand("UPDATE dbo.Contribution SET PeopleId={1} WHERE PeopleId={0}", person.PeopleId, person.Family.HeadOfHouseholdId); var message = count == 1 ? $"1 giving record was transferred successfully." : $"{count} giving records were transferred successfully."; return(Json(new { status = "OK", message })); }
public ActionResult ResetTips() { CurrentDatabase.ExecuteCommand("DELETE dbo.Preferences WHERE Preference LIKE 'hide-tip-%' AND UserId = {0}", Util.UserId); var d = Session["preferences"] as Dictionary <string, string>; var keys = d.Keys.Where(kk => kk.StartsWith("hide-tip-")).ToList(); foreach (var k in keys) { d.Remove(k); } if (Request.UrlReferrer != null) { return(Redirect(Request.UrlReferrer.ToString())); } return(Redirect("/")); }
public ContentResult Edit(string id, string value) { var a = id.SplitStr("."); var iid = a[0].Substring(1).ToInt(); if (id.StartsWith("t")) { CurrentDatabase.ExecuteCommand( "update lookup." + a[1] + " set Description = {0} where id = {1}", value, iid); } else if (id.StartsWith("c")) { CurrentDatabase.ExecuteCommand( "update lookup." + a[1] + " set Code = {0} where id = {1}", value, iid); } return(Content(value)); }
public ActionResult TagUploadPeopleIds(string name, string text, bool newtag) { var q = from line in text.Split('\n') select line.GetCsvToken(1, sep : "\t").ToInt(); if (newtag) { var tag = CurrentDatabase.FetchTag(name, Util.UserPeopleId, DbUtil.TagTypeId_Personal); if (tag != null) { CurrentDatabase.ExecuteCommand("delete TagPerson where Id = {0}", tag.Id); } } foreach (var pid in q) { Person.Tag(CurrentDatabase, pid, name, CurrentDatabase.CurrentUser.PeopleId, DbUtil.TagTypeId_Personal); CurrentDatabase.SubmitChanges(); } return(Redirect("/Tags?tag=" + name)); }
public ActionResult DeleteAll(string field, string type, string value) { var ev = CurrentDatabase.PeopleExtras.Where(ee => ee.Field == field).FirstOrDefault(); if (ev == null) { return(Content("error: no field")); } switch (type.ToLower()) { case "code": CurrentDatabase.ExecuteCommand("delete PeopleExtra where field = {0} and StrValue = {1}", field, value); break; case "bit": CurrentDatabase.ExecuteCommand("delete PeopleExtra where field = {0} and BitValue = {1}", field, value); break; case "int": CurrentDatabase.ExecuteCommand("delete PeopleExtra where field = {0} and IntValue is not null", field); break; case "date": CurrentDatabase.ExecuteCommand("delete PeopleExtra where field = {0} and DateValue is not null", field); break; case "text": CurrentDatabase.ExecuteCommand("delete PeopleExtra where field = {0} and Data is not null", field); break; case "?": CurrentDatabase.ExecuteCommand("delete PeopleExtra where field = {0} and data is null and datevalue is null and intvalue is null", field); break; } return(Content("done")); }
public ActionResult AddAbsentsToMeeting(int id) { CurrentDatabase.ExecuteCommand("dbo.AddAbsentsToMeeting {0}", id); return(Redirect($"/Meeting/{id}")); }
public void SendEmails() { var tag = CurrentDatabase.FetchOrCreateTag(Util.SessionId, Util.UserPeopleId, CurrentDatabase.NextTagId); CurrentDatabase.ExecuteCommand("delete TagPerson where Id = {0}", tag.Id); CurrentDatabase.TagAll(pids, tag); var dt = new DateTime(ticks); foreach (var id in pids) { var vr = new SubRequest { AttendId = attend.AttendId, RequestorId = person.PeopleId, Requested = dt, SubstituteId = id, }; attend.SubRequests.Add(vr); } CurrentDatabase.SubmitChanges(); var qb = CurrentDatabase.ScratchPadCondition(); qb.Reset(); qb.AddNewClause(QueryType.HasMyTag, CompareType.Equal, $"{tag.Id},temp"); attend.Commitment = CmsData.Codes.AttendCommitmentCode.FindSub; qb.Save(CurrentDatabase); var rurl = CurrentDatabase.ServerLink($"/OnlineReg/VolSubReport/{attend.AttendId}/{person.PeopleId}/{dt.Ticks}"); var reportlink = $@"<a href=""{rurl}"">Substitute Status Report</a>"; var list = CurrentDatabase.PeopleFromPidString(org.NotifyIds).ToList(); //list.Insert(0, person); CurrentDatabase.Email(person.FromEmail, list, "Volunteer Substitute Commitment for " + org.OrganizationName, $@" <p>{person.Name} has requested a substitute on {attend.MeetingDate:MMM d} at {attend.MeetingDate:h:mm tt}.</p> <blockquote> {reportlink} </blockquote>"); // Email subs var m = new MassEmailer(qb.Id); m.Subject = subject; m.Body = message; m.FromName = person.Name; m.FromAddress = person.FromEmail; var eqid = m.CreateQueue(transactional: true).Id; string host = CurrentDatabase.Host; // save these from HttpContext to set again inside thread local storage var useremail = Util.UserEmail; var isinroleemailtest = HttpContextFactory.Current.User.IsInRole("EmailTest"); Log("Send Emails"); HostingEnvironment.QueueBackgroundWorkItem(ct => { try { var db = CMSDataContext.Create(host); // set these again inside thread local storage Util.UserEmail = useremail; Util.IsInRoleEmailTest = isinroleemailtest; db.SendPeopleEmail(eqid); } catch (Exception ex) { Log("Email Error"); var ex2 = new Exception("Emailing error for queueid " + eqid, ex); ErrorLog errorLog = ErrorLog.GetDefault(null); errorLog.Log(new Error(ex2)); var db = CMSDataContext.Create(host); // set these again inside thread local storage Util.UserEmail = useremail; Util.IsInRoleEmailTest = isinroleemailtest; var equeue = db.EmailQueues.Single(ee => ee.Id == eqid); equeue.Error = ex.Message.Truncate(200); db.SubmitChanges(); } }); }