public ActionResult BatchUpload(DateTime?date, HttpPostedFileBase file, int?fundid, string text) { if (!date.HasValue) { ModelState.AddModelError("date", "Date is required"); return(View("Batch")); } var fromFile = false; string s; if (file != null) { var buffer = new byte[file.ContentLength]; file.InputStream.Read(buffer, 0, file.ContentLength); System.Text.Encoding enc; if (buffer[0] == 0xFF && buffer[1] == 0xFE) { enc = new System.Text.UnicodeEncoding(); s = enc.GetString(buffer, 2, buffer.Length - 2); } else { enc = new System.Text.ASCIIEncoding(); s = enc.GetString(buffer); } fromFile = true; } else { if (String.IsNullOrWhiteSpace(text)) { ModelState.AddModelError("textarea", "Text is required when no file is uploaded."); return(View("Batch")); } s = text; } try { var id = BatchImportContributions.BatchProcess(s, date.Value, fundid, fromFile); if (id.HasValue) { return(Redirect("/PostBundle/" + id)); } return(RedirectToAction("Batch")); } catch (Exception ex) { return(PageMessage(ViewExtensions2.Markdown(ex.Message).ToString())); } }
public ActionResult BatchUpload(DateTime date, HttpPostedFileBase file, int?fundid, string text) { var fromFile = false; string s; if (file != null) { var buffer = new byte[file.ContentLength]; file.InputStream.Read(buffer, 0, file.ContentLength); System.Text.Encoding enc; if (buffer[0] == 0xFF && buffer[1] == 0xFE) { enc = new System.Text.UnicodeEncoding(); s = enc.GetString(buffer, 2, buffer.Length - 2); } else { enc = new System.Text.ASCIIEncoding(); s = enc.GetString(buffer); } fromFile = true; } else { s = text; } try { var id = BatchImportContributions.BatchProcess(s, date, fundid, fromFile); if (id.HasValue) { return(Redirect("/PostBundle/" + id)); } return(RedirectToAction("Batch")); } catch (Exception ex) { return(PageMessage(ViewExtensions2.Markdown(ex.Message).ToString())); } }
private ReturnResult AddOrgMembers(int id, int origin, int membertypeid = MemberTypeCode.Member, bool pending = false) { string message = null; if (id > 0) { var org = DbUtil.Db.LoadOrganizationById(id); if (pending == false && PendingList.Count == 1 && org.AllowAttendOverlap != true) { var om = DbUtil.Db.OrganizationMembers.FirstOrDefault(mm => mm.OrganizationId != id && mm.MemberTypeId != 230 && // inactive mm.MemberTypeId != 500 && // inservice mm.Organization.AllowAttendOverlap != true && mm.PeopleId == PendingList[0].PeopleId && mm.Organization.OrgSchedules.Any(ss => DbUtil.Db.OrgSchedules.Any(os => os.OrganizationId == id && os.ScheduleId == ss.ScheduleId))); if (om != null) { message = ViewExtensions2.Markdown($@" **Already a member of {om.OrganizationId} (orgid) with same schedule** You can do one of these things: * Drop the person from the other org first * Use the 'move' feature to transfer them to the new org * Use Allow Attendance Overlap, if appropriate * See <a href=""http://docs.touchpointsoftware.com/Organizations/AlreadyAMember.html"" title=""Already a Member"" target=""_blank"">this help article</a> ").ToString(); message = $@"<div style=""text-align: left"">{message}</div>"; return(new ReturnResult { close = true, how = "CloseAddDialog", error = message, from = AddContext }); } } foreach (var p in PendingList) { AddPerson(p, PendingList, origin, EntryPointId); var om = OrganizationMember.InsertOrgMembers(DbUtil.Db, id, p.PeopleId.Value, membertypeid, Util.Now, null, pending); if (membertypeid == MemberTypeCode.InActive && org.IsMissionTrip == true) { om.AddToGroup(DbUtil.Db, "Sender"); } if (om.CreatedDate.HasValue) { if ((DateTime.Now - om.CreatedDate.Value).TotalSeconds < 5) { var type = pending ? "Pending" : membertypeid == MemberTypeCode.InActive ? "Inactive" : membertypeid == MemberTypeCode.Prospect ? "Prospect" : "Member"; DbUtil.LogActivity($"Org{type} Add", om.OrganizationId, om.PeopleId); } } } DbUtil.Db.SubmitChanges(); DbUtil.Db.UpdateMainFellowship(id); } return(new ReturnResult { close = true, how = "rebindgrids", error = message, from = AddContext }); }