public ActionResult SubmitPropertiBekas(FormCollection formCollection) { if (System.Web.HttpContext.Current.Session[Variables._varEncryptedKey] == null) { return(SessionExpired()); } var formData = DecryptObject(formCollection[PAYLOAD]); // decrypt from js string randomKey = System.Web.HttpContext.Current.Session[Variables._varEncryptedKey].ToString(); string MaxSubmit = AESEncrytDecry.DecryptStringAES(randomKey, formData["MaxSubmit"]); PropertiBekas PropertiBekas = new PropertiBekas(); var culture = new System.Globalization.CultureInfo(SC.Context.Language.Name); var properties = PropertiBekas.GetType().GetProperties(); for (int i = 0; i < properties.Length; i++) { try { if (!string.IsNullOrWhiteSpace(AESEncrytDecry.DecryptStringAES(randomKey, formData[properties[i].Name]))) { properties[i].SetValue(PropertiBekas, Convert.ChangeType(AESEncrytDecry.DecryptStringAES(randomKey, formData[properties[i].Name]), properties[i].PropertyType, culture), null); } } catch { /* just continue ignore this error */ } } PropertiBekas.IDPROPERTIBEKAS = Guid.NewGuid(); PropertiBekas.CREATED = DateTime.Now; SubmitData(PropertiBekas, MaxSubmit); return(Json(new { success = true })); }
public int CountEmail(PropertiBekas oPropertiBekas) { int totalEmail = 0; using (var db = Factory.DbEntities) { try { //// OBSOLET //totalEmail = db.PropertiBekas.Where(x => x.EMAIL.ToLower().Contains(oPropertiBekas.EMAIL.ToLower())) // .Where(x => x.NAMAPROPERTI.ToLower().Contains(oPropertiBekas.NAMAPROPERTI.ToLower())) // .Where(x => x.CREATED == DateTime.Today) // .Count(); totalEmail = oPropertiBekas.Get(db).Count(); } catch (Exception ex) { StringBuilder sb = new StringBuilder(); sb.AppendLine(ex.Message); //lg.LogWrite(sb.ToString()); } } return(totalEmail); }
public bool SubmitData(PropertiBekas oPropertiBekas, string MaxSubmit) { int countEmail = CountEmail(oPropertiBekas); if (countEmail >= int.Parse(MaxSubmit)) { return(false); } else { //methodsendEmail EmailContent EmailContent = GetEmailContent(Sitecore.Feature.Library.Helper.Variables._emailTemplatePropertyBekas); //Email EmailContent.EmailBody = EmailContent.EmailBody.Replace("[Customer Name]", oPropertiBekas.EMAIL); Sitecore.Feature.Library.Helpers.LibraryHelpers.SendEmail(oPropertiBekas.EMAIL, EmailContent.EmailFrom, EmailContent.Subject, EmailContent.EmailBody); //Get Email To Add(oPropertiBekas); return(true); } }
public void Add(PropertiBekas oPropertiBekas) { using (var db = Factory.DbEntities) { try { //// OBSOLET //db.PropertiBekas.Add(oPropertiBekas); //db.SaveChanges(); oPropertiBekas.Insert(db); } catch (Exception ex) { StringBuilder sb = new StringBuilder(); sb.AppendLine(ex.Message); //lg.LogWrite(sb.ToString()); } } }