private int StoreBGImage(HttpPostedFileBase file, int?imageId) { var stream = file.InputStream; var bits = new byte[stream.Length]; stream.Read(bits, 0, bits.Length); if (imageId == null) { return(Image.NewImageFromBits(bits, CurrentImageDatabase, true).Id); } return(CurrentImageDatabase.UpdateImageFromBits(imageId.Value, bits).Id); }
public ActionResult Delete(int id, int peopleId) { var form = CurrentDatabase.VolunteerForms.Single(f => f.Id == id); CurrentImageDatabase.DeleteOnSubmit(form.SmallId); CurrentImageDatabase.DeleteOnSubmit(form.MediumId); CurrentImageDatabase.DeleteOnSubmit(form.LargeId); CurrentDatabase.VolunteerForms.DeleteOnSubmit(form); CurrentDatabase.SubmitChanges(); return(Redirect($"/Volunteering/{peopleId}#tab_documents")); }
public ContentResult DeleteImage(string id) { var iid = id.Substring(1).ToInt(); var img = CurrentImageDatabase.Images.SingleOrDefault(m => m.Id == iid); if (img == null) { return(Content("#r0")); } CurrentImageDatabase.Images.DeleteOnSubmit(img); CurrentImageDatabase.SubmitChanges(); return(Content("#r" + iid)); }
public ActionResult ContentUpdate(int id, string name, string title, string body, bool?snippet, int?roleid, string contentKeyWords, string stayaftersave = null) { var content = CurrentDatabase.Contents.SingleOrDefault(c => c.Id == id); content.Name = name; content.Title = string.IsNullOrWhiteSpace(title) ? name : title; content.Body = body?.Trim(); content.RemoveGrammarly(); content.RoleID = roleid ?? 0; content.Snippet = snippet; content.SetKeyWords(CurrentDatabase, contentKeyWords.SplitStr(",").Select(vv => vv.Trim()).ToArray()); if (content.TypeID == ContentTypeCode.TypeEmailTemplate) { try { var captureWebPageBytes = CaptureWebPageBytes(body, 100, 150); var ii = CurrentImageDatabase.UpdateImageFromBits(content.ThumbID, captureWebPageBytes); if (ii == null) { content.ThumbID = ImageData.Image.NewImageFromBits(captureWebPageBytes, CurrentImageDatabase).Id; } content.DateCreated = DateTime.Now; content.CreatedBy = Util.UserName; } catch (Exception ex) { var errorLog = ErrorLog.GetDefault(null); errorLog.Log(new Error(ex)); } } CurrentDatabase.SubmitChanges(); if (string.Compare(content.Name, "CustomReportsMenu", StringComparison.OrdinalIgnoreCase) == 0) { try { var list = ReportsMenuModel.CustomItems1; } catch (Exception ex) { if (ex is System.Xml.XmlException) { return(Content(Util.EndShowMessage(ex.Message, "javascript: history.go(-1)", "There is invalid XML in this document. Go Back to Repair"))); } } } else if (string.Compare(content.Name, "CustomReports", StringComparison.OrdinalIgnoreCase) == 0) { try { var list = CurrentDatabase.ViewCustomScriptRoles.ToList(); } catch (Exception ex) { if (ex.Message.Contains("XML parsing", ignoreCase: true)) { return(Content(Util.EndShowMessage(ex.InnerException?.Message, "javascript: history.go(-1)", "There is invalid XML in this document. Go Back to Repair"))); } } } else if (string.Compare(content.Name, "StandardExtraValues2", StringComparison.OrdinalIgnoreCase) == 0) { try { CmsData.ExtraValue.Views.GetStandardExtraValues(CurrentDatabase, "People"); } catch (InvalidOperationException ex) { if (ex.InnerException is System.Xml.XmlException) { return(Content(Util.EndShowMessage(ex.InnerException.Message, "javascript: history.go(-1)", "There is invalid XML in this document. Go Back to Repair"))); } } } if (stayaftersave == "true") { return(RedirectToAction("ContentEdit", new { id, snippet })); } var url = GetIndexTabUrl(content); return(Redirect(url)); }
public ActionResult Upload(string data) { CheckScanAuthentication authentication = new CheckScanAuthentication(); authentication.authenticate(); if (authentication.hasError()) { return(CheckScanMessage.createLoginErrorReturn(authentication)); } User user = authentication.getUser(); if (!user.InRole("Finance")) { return(CheckScanMessage.createErrorReturn("Finance role is required for check scanning")); } CheckInMessage message = CheckInMessage.createFromString(data); List <CheckScanEntry> entries = JsonConvert.DeserializeObject <List <CheckScanEntry> >(message.data); BundleHeader header; if (message.id == 0) { header = new BundleHeader { BundleHeaderTypeId = 1, BundleStatusId = BundleStatusCode.Open, CreatedBy = user.UserId, ContributionDate = DateTime.Now, CreatedDate = DateTime.Now, FundId = CurrentDatabase.Setting("DefaultFundId", "1").ToInt(), RecordStatus = false, TotalCash = 0, TotalChecks = 0, TotalEnvelopes = 0, BundleTotal = 0 }; CurrentDatabase.BundleHeaders.InsertOnSubmit(header); CurrentDatabase.SubmitChanges(); } else { header = (from h in CurrentDatabase.BundleHeaders where h.BundleHeaderId == message.id select h).FirstOrDefault(); } CheckScanMessage response = new CheckScanMessage(); if (header != null) { foreach (CheckScanEntry entry in entries) { Other other = new Other(); other.Created = DateTime.Now; other.UserID = user.UserId; if (entry.front.Length > 0) { other.First = Convert.FromBase64String(entry.front); } if (entry.back.Length > 0) { other.Second = Convert.FromBase64String(entry.back); } CurrentImageDatabase.Others.InsertOnSubmit(other); CurrentImageDatabase.SubmitChanges(); var detail = new BundleDetail { BundleHeaderId = header.BundleHeaderId, CreatedBy = user.UserId, CreatedDate = DateTime.Now }; string bankAccount = entry.routing.Length > 0 && entry.account.Length > 0 ? Util.Encrypt(entry.routing + "|" + entry.account) : ""; detail.Contribution = new Contribution { CreatedBy = user.UserId, CreatedDate = detail.CreatedDate, FundId = header.FundId ?? 0, PeopleId = FindPerson(CurrentDatabase, entry.routing, entry.account), ContributionDate = header.ContributionDate, ContributionAmount = decimal.Parse(entry.amount), ContributionStatusId = 0, ContributionTypeId = 1, ContributionDesc = entry.notes, CheckNo = entry.number, BankAccount = bankAccount, ImageID = other.Id }; header.BundleDetails.Add(detail); CurrentDatabase.SubmitChanges(); } response.setSuccess(); response.id = header.BundleHeaderId; } else { response.setError(1, "Invalid Bundle ID"); } return(response); }