public async Task <ActionResult> DeleteConfirmed(int id) { emailrecord emailrecord = await db.EmailRecord.FindAsync(id); db.EmailRecord.Remove(emailrecord); await db.SaveChangesAsync(); return(Json(new { Success = true }, JsonRequestBehavior.AllowGet)); }
public async Task <ActionResult> Create([Bind(Include = "Id,FirstName,LastName,Phone,Email,CreditCard,CreditCardType,CardExpMo,CardExpYr,UserID,CreatedDate,UpdatedDate,Sort,Description,Notes,UserName,Password,ConfirmPassword")] Customer customer) { var _controller = new AccountController(); if (ModelState.IsValid) { customer.CreatedDate = DateTime.Now; customer.UpdatedDate = DateTime.Now; customer.Sort = 33; db.Customers.Add(customer); var user = new ApplicationUser() { UserName = customer.UserName, CreatedDate = DateTime.Now, UpdatedDate = DateTime.Now }; IdentityResult result = await _controller.UserManager.CreateAsync(user, customer.Password); if (result.Succeeded) { customer.UserID = user.Id; db.SaveChanges(); _controller.UserManager.AddToRole(user.Id, "Customer"); string email = customer.Email; string username = customer.UserName; string adminemail = ConfigurationManager.AppSettings["adminemail"].ToString(); string admintemple = ConfigurationManager.AppSettings["admintempleforcustomer"].ToString(); string subject = ConfigurationManager.AppSettings["subject"].ToString(); string AdminUserName = ConfigurationManager.AppSettings["adminusername"].ToString(); var sendemail = new EmailService.Service.EmailService(); sendemail.SendEmail(email, "addcustomer.html", "verfication", username); sendemail.SendEmail(adminemail, admintemple, subject, AdminUserName); this.AddNotification("Customer Created successfully.", NotificationType.SUCCESS); #region Saveinemailrecord var emailrecord = new emailrecord(); emailrecord.Email_Sender = "*****@*****.**"; emailrecord.Email_Receiver = email; emailrecord.Send_Date = DateTime.Now.ToString(); emailrecord.Subject = subject; emailrecord.Message = "New Customer Added "; db.EmailRecord.Add(emailrecord); db.SaveChanges(); #endregion return(RedirectToAction("Index")); } else { AddErrors(result); } } return(View(customer)); }
public async Task <ActionResult> Edit([Bind(Include = "Id,Email_Sender,Email_Receiver,Send_Date,Subject,Message")] emailrecord emailrecord) { if (ModelState.IsValid) { db.Entry(emailrecord).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(emailrecord)); }
public async Task <ActionResult> Create([Bind(Include = "Id,Email_Sender,Email_Receiver,Send_Date,Subject,Message")] emailrecord emailrecord) { if (ModelState.IsValid) { db.EmailRecord.Add(emailrecord); await db.SaveChangesAsync(); this.AddNotification("Email record successfully.", NotificationType.SUCCESS); return(RedirectToAction("Index")); } return(View(emailrecord)); }
// GET: /EmailRecords/Details/5 public async Task <ActionResult> Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } emailrecord emailrecord = await db.EmailRecord.FindAsync(id); if (emailrecord == null) { return(HttpNotFound()); } return(View(emailrecord)); }