public JsonResult UpdateOrderStatus(int id) { try { Chatpata_dabbaEntities1 Entity = new Chatpata_dabbaEntities1(); OrderMaster OM = new OrderMaster(); var details = Entity.OrderMasters.Where(q => q.OrderId == id).FirstOrDefault(); details.Status = "Accept"; Entity.Entry(details).State = System.Data.Entity.EntityState.Modified; Entity.SaveChanges(); if (details.StartDate.Day <= DateTime.Now.Day && details.EndDate.Day >= DateTime.Now.Day) { DailyOrder dor = new DailyOrder(); dor.CustId = details.CustomerId; dor.OrderId = id; dor.Date = DateTime.Now; dor.Status = "Pending"; dor.Code = 0; Entity.DailyOrders.Add(dor); Entity.SaveChanges(); } return(Json("Accept", JsonRequestBehavior.AllowGet)); } catch (Exception e) { return(Json("Error", JsonRequestBehavior.AllowGet)); } }
public JsonResult UpdateStatus(int id, string st) { try { Chatpata_dabbaEntities1 Entity = new Chatpata_dabbaEntities1(); RequestMaster rm = new RequestMaster(); var details = Entity.RequestMasters.Where(q => q.Id == id).FirstOrDefault(); if (st == "Accept") { details.Status = "Accept"; Entity.Entry(details).State = System.Data.Entity.EntityState.Modified; Entity.SaveChanges(); return(Json("Accept", JsonRequestBehavior.AllowGet)); } else if (st == "Reject") { details.Status = "Reject"; Entity.Entry(details).State = System.Data.Entity.EntityState.Modified; Entity.SaveChanges(); return(Json("Reject", JsonRequestBehavior.AllowGet)); } else { return(Json("Error", JsonRequestBehavior.AllowGet)); } } catch (Exception e) { return(Json("Error", JsonRequestBehavior.AllowGet)); } }
public ActionResult Complain(FormCollection frm) { Chatpata_dabbaEntities1 Entity = new Chatpata_dabbaEntities1(); Complain com = new Complain(); var d = 0; if (frm["Dname"] != null) { var dname = frm["Dname"].ToString(); var did = Entity.CustomerMasters.Where(q => q.FirstName.Equals(dname)).FirstOrDefault(); if (did != null) { d = did.CustId; } } com.CustId = Convert.ToInt32(Session["UserId"]); com.Date = DateTime.Now; com.Status = "complain"; com.Description = Convert.ToString(frm["Complain"]); com.DriverId = d; Entity.Complains.Add(com); Entity.SaveChanges(); return(RedirectToAction("Customer")); }
public ActionResult UpdateProfile(CustomerMaster ProfileInfo, FormCollection frm, HttpPostedFileBase file) { try { ProfileInfo.CustId = Convert.ToInt32(frm["CustId"]); Chatpata_dabbaEntities1 cd = new Chatpata_dabbaEntities1(); var user = cd.CustomerMasters.Where(q => q.CustId == ProfileInfo.CustId).FirstOrDefault(); var newFileName = ""; if (file != null) { string pic = System.IO.Path.GetFileName(file.FileName); FileInfo fi = new FileInfo(pic); string fileextension = fi.Extension.Substring(1).ToUpper(); newFileName = Convert.ToString(Guid.NewGuid()) + "." + fileextension; var FolderPath = "~/Images/"; var Imgpath = Path.Combine(Server.MapPath(FolderPath), newFileName); file.SaveAs(Imgpath); newFileName = FolderPath + newFileName; } ProfileInfo.Image = newFileName; ProfileInfo.Birthdate = user.Birthdate; cd.Entry(user).State = System.Data.Entity.EntityState.Modified; cd.SaveChanges(); return(RedirectToAction("Customer")); } catch (Exception ex) { throw ex; } }
public ActionResult CodeRetrival(FormCollection frm) { var code = Convert.ToString(frm["code"]); Chatpata_dabbaEntities1 Entity = new Chatpata_dabbaEntities1(); DailyOrder DO = new DailyOrder(); var cid = Convert.ToInt32(Session["UserID"]); // var dbcode = Entity.DailyOrders.Where(q => q.CustId == cid && q.Code == code).Count(); var dbcode = Entity.DailyStatusChange().LastOrDefault(); if (dbcode != null) { // var dbcode1 = Entity.DailyOrders.Where(q => q.CustId == cid && q.Code == code).ToList(); // var orderstatus=Entity. // dbcode1[0].Status = "Delivered"; var orderdetails = Entity.DailyOrders.Where(q => q.Date.Day == DateTime.Now.Day && q.Date.Month == DateTime.Now.Month).ToList(); var data = orderdetails.Where(q => Convert.ToDecimal(q.Code) == Convert.ToDecimal(dbcode.rcode) && q.OrderId == dbcode.OrderId).ToList(); // var orderdetails = Entity.DailyOrderData().Where(q => q.CustId == dbcode.CustId).FirstOrDefault(); //var orderchange = Entity.DailyOrders.Where(q => q.CustId == orderdetails.CustId).ToList(); data[0].Status = "Delivered"; Entity.Entry(data[0]).State = System.Data.Entity.EntityState.Modified; Entity.SaveChanges(); return(RedirectToAction("ThankYouPage")); } else { return(RedirectToAction("CodeRetrival")); } }
public ActionResult Payment(FormCollection frm, OrderMaster OM) { try { if (Session["UserID"] == null) { return(RedirectToAction("Index", "Home")); } var Id = Convert.ToInt32(Session["UserId"]); Chatpata_dabbaEntities1 Entity = new Chatpata_dabbaEntities1(); OM.OrderId = Convert.ToInt32(frm["OrderID"]); var orderdetails = Entity.OrderMasters.Where(q => q.OrderId == OM.OrderId).FirstOrDefault(); if (Convert.ToString(frm["Method"]) == "online") { orderdetails.PaymentMode = "Online"; } if (Convert.ToString(frm["Method"]) == "cash") { orderdetails.PaymentMode = "COD"; } Entity.Entry(orderdetails).State = System.Data.Entity.EntityState.Modified; Entity.SaveChanges(); return(RedirectToAction("OrderReview")); } catch (Exception e) { throw e; } }
public ActionResult AddMenu(FormCollection frm, HttpPostedFileBase file) { try { Chatpata_dabbaEntities1 Entity = new Chatpata_dabbaEntities1(); MenuMaster menu = new MenuMaster(); var newFileName = ""; if (file != null) { string pic = System.IO.Path.GetFileName(file.FileName); FileInfo fi = new FileInfo(pic); string fileextension = fi.Extension.Substring(1).ToUpper(); newFileName = Convert.ToString(Guid.NewGuid()) + "." + fileextension; var FolderPath = "~/Images/"; var Imgpath = Path.Combine(Server.MapPath(FolderPath), newFileName); file.SaveAs(Imgpath); newFileName = FolderPath + newFileName; } menu.Name = Convert.ToString(frm["Name"]); menu.Description = Convert.ToString(frm["Description"]); menu.Image = Convert.ToString(frm["Image"]); menu.Price = Convert.ToDecimal(frm["Price"]); menu.Image = newFileName; Entity.MenuMasters.Add(menu); Entity.SaveChanges(); return(RedirectToAction("Admin", "Admin")); } catch (Exception e) { throw e; } }
public ActionResult Forgotque(FormCollection frm) { try { Chatpata_dabbaEntities1 EntityFile = new Chatpata_dabbaEntities1(); var email = Convert.ToString(frm["Email"]); var user = EntityFile.CustomerMasters.Where(q => q.EmailID == email).FirstOrDefault(); //Session["UserID"]=details.CustId; string pass = GenerateRandomPassword(6); int chkmail = Mail.SendMail("Your New Password", pass, email); user.Password = MD5Crypt.Encrypt(pass, "Dabba"); EntityFile.Entry(user).State = System.Data.Entity.EntityState.Modified; EntityFile.SaveChanges(); return(RedirectToAction("Index")); } catch (Exception ex) { return(RedirectToAction("Forgotpass_new", "Home")); } }
public ActionResult EditMenu(MenuMaster menuinfo, HttpPostedFileBase file) { try { Chatpata_dabbaEntities1 EntityFile = new Chatpata_dabbaEntities1(); var newFileName = ""; if (file != null) { string pic = System.IO.Path.GetFileName(file.FileName); FileInfo fi = new FileInfo(pic); string fileextension = fi.Extension.Substring(1).ToUpper(); newFileName = Convert.ToString(Guid.NewGuid()) + "." + fileextension; var FolderPath = "~/Images/"; var Imgpath = Path.Combine(Server.MapPath(FolderPath), newFileName); file.SaveAs(Imgpath); newFileName = FolderPath + newFileName; } menuinfo.Image = newFileName; EntityFile.Entry(menuinfo).State = System.Data.Entity.EntityState.Modified; EntityFile.SaveChanges(); return(RedirectToAction("ViewMenu")); } catch (Exception e) { return(RedirectToAction("Login", "Home")); } }
public ActionResult DOEntry() { Chatpata_dabbaEntities1 Entity = new Chatpata_dabbaEntities1(); OrderMaster OM = new OrderMaster(); DailyOrder DO = new DailyOrder(); var currentdate = Convert.ToDateTime(DateTime.Now.ToShortDateString()); var orderdetails = Entity.OrderMasters.Where(q => q.StartDate <= currentdate && q.EndDate >= currentdate && (q.Status.Equals("Accept") || q.Status.Equals("Delivered"))).OrderBy(q => q.CustomerMaster.FirstName).ToList(); // var cname = orderdetails.OrderBy(q => q.MenuId).ToList(); if (orderdetails != null) { foreach (var order in orderdetails.ToList()) { DO.CustId = Convert.ToInt32(order.CustomerId); DO.OrderId = Convert.ToInt32(order.OrderId); DO.Date = DateTime.Now; DO.Status = "Pending"; DO.Code = 0; Entity.DailyOrders.Add(DO); Entity.SaveChanges(); } } return(RedirectToAction("ViewDailyOrder")); }
public ActionResult CodeRetrival() { try { if (Session["UserID"] == null) { return(RedirectToAction("Index", "Home")); } Chatpata_dabbaEntities1 Entity = new Chatpata_dabbaEntities1(); DailyOrder DO = new DailyOrder(); var dbcode = Entity.DailyStatusChange().LastOrDefault(); var orderdetails = Entity.DailyOrders.Where(q => q.Date.Day == DateTime.Now.Day && q.Date.Month == DateTime.Now.Month).ToList(); var code = orderdetails.Where(q => Convert.ToDecimal(q.Code) == Convert.ToDecimal(dbcode.rcode) && q.OrderId == dbcode.OrderId).ToList(); if (code.Count == 0) { var Orders = Entity.DailyOrderData().Where(q => q.Date.Day == DateTime.Now.Day && q.Date.Month == DateTime.Now.Month).OrderBy(q => q.Status).ToList(); return(View(Orders)); } else { code[0].Status = "Delivered"; Entity.Entry(code[0]).State = System.Data.Entity.EntityState.Modified; Entity.SaveChanges(); var Orders = Entity.DailyOrderData().Where(q => q.Date.Day == DateTime.Now.Day && q.Date.Month == DateTime.Now.Month).OrderBy(q => q.Status).ToList(); return(View(Orders)); } } catch (Exception e) { throw e; } }
public ActionResult UpdateProfile(CustomerMaster ProfileInfo, FormCollection frm) { try { if (Session["UserID"] == null) { return(RedirectToAction("Index", "Home")); } var id = Convert.ToInt32(Session["UserID"]); ProfileInfo.CustId = Convert.ToInt32(frm["CustId"]); Chatpata_dabbaEntities1 cd = new Chatpata_dabbaEntities1(); var user = cd.CustomerMasters.Where(q => q.CustId == ProfileInfo.CustId).FirstOrDefault(); ProfileInfo.Birthdate = user.Birthdate; ProfileInfo.FirstName = user.FirstName; user.LastName = Convert.ToString(frm["LastName"]); user.Address1 = Convert.ToString(frm["Address1"]); user.Address2 = Convert.ToString(frm["Address2"]); user.Address3 = Convert.ToString(frm["Address3"]); user.Pincode = Convert.ToString(frm["Pincode"]); user.PhoneNo = Convert.ToString(frm["PhoneNo"]); cd.Entry(user).State = System.Data.Entity.EntityState.Modified; cd.SaveChanges(); return(RedirectToAction("Customer")); } catch (Exception ex) { throw ex; } }
public ActionResult Verifychpass(FormCollection frm) { try { if (Session["UserID"] == null) { return(RedirectToAction("Index", "Home")); } Chatpata_dabbaEntities1 en = new Chatpata_dabbaEntities1(); CustomerMaster cm = new CustomerMaster(); var pass = Convert.ToString(frm["new_pass"]); var id = Convert.ToInt32(Session["UserID"]); var user = en.CustomerMasters.Where(q => q.CustId == id).FirstOrDefault(); user.Password = MD5Crypt.Encrypt(pass, "Dabba"); en.Entry(user).State = System.Data.Entity.EntityState.Modified; en.SaveChanges(); return(RedirectToAction("Admin", "Admin")); } catch (Exception ex) { return(RedirectToAction("Admin")); } }
public JsonResult AddMenuItem(int Id, int menuid) { try { Chatpata_dabbaEntities1 Entity = new Chatpata_dabbaEntities1(); MenuItem menuitem = new MenuItem(); var chk = Entity.MenuItems.Where(q => q.ItemId == Id && q.MenuId == menuid).FirstOrDefault(); if (chk != null) { return(Json("item", JsonRequestBehavior.AllowGet)); } else { menuitem.ItemId = Id; menuitem.MenuId = menuid; Entity.MenuItems.Add(menuitem); Entity.SaveChanges(); return(Json("Success", JsonRequestBehavior.AllowGet)); } } catch { return(Json("Error", JsonRequestBehavior.AllowGet)); } }
public JsonResult CancelOrder(int oid) { try { Chatpata_dabbaEntities1 en = new Chatpata_dabbaEntities1(); var currentTime = Convert.ToDateTime(DateTime.Now.ToShortTimeString()); var time = Convert.ToDateTime("10:00:00 AM"); var id = Convert.ToInt32(Session["UserID"]); if (currentTime < time) { OrderMaster om = new OrderMaster(); var ss = en.OrderMasters.Where(q => q.OrderId == oid && q.CustomerId == id).FirstOrDefault(); DailyOrder Do = new DailyOrder(); var details = en.DailyOrders.Where(q => q.OrderId == oid && q.CustId == id && q.Date.Day == DateTime.Now.Day && q.Date.Month == DateTime.Now.Month).ToList(); details[0].Status = "Cancel"; if (ss.PaymentMode == "Online") { decimal[] rid = (en.OrderList().Where(q => q.OrderId == oid).Select(q => q.Price)).ToArray(); decimal r = Convert.ToDecimal((((rid[0]) * 10) / 100) + rid[0]); ss.Ecoupon = r; en.Entry(details).State = System.Data.Entity.EntityState.Modified; en.SaveChanges(); } en.Entry(details[0]).State = System.Data.Entity.EntityState.Modified; en.SaveChanges(); return(Json("Cancel", JsonRequestBehavior.AllowGet)); } else { return(Json("Error", JsonRequestBehavior.AllowGet)); } } catch (Exception e) { return(Json("Error", JsonRequestBehavior.AllowGet)); } }
public JsonResult DeleteArea(int id) { try { Chatpata_dabbaEntities1 model = new Chatpata_dabbaEntities1(); var UserDetails = model.AreaMasters.Where(q => q.Id == id).FirstOrDefault(); model.AreaMasters.Remove(UserDetails); model.SaveChanges(); return(Json("Success", JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json("Error", JsonRequestBehavior.AllowGet)); } }
public JsonResult DeleteMenu(int id) { try { Chatpata_dabbaEntities1 EntityFile = new Chatpata_dabbaEntities1(); var MenuDetails = EntityFile.MenuMasters.Where(q => q.Id == id).FirstOrDefault(); EntityFile.MenuMasters.Remove(MenuDetails); EntityFile.SaveChanges(); return(Json("Success", JsonRequestBehavior.AllowGet)); } catch { return(Json("Error", JsonRequestBehavior.AllowGet)); } }
public JsonResult DeleteMenuItem(int Id, int menuId) { try { Chatpata_dabbaEntities1 EntityFile = new Chatpata_dabbaEntities1(); var ItemDetails = EntityFile.MenuItems.Where(q => q.ItemId == Id && q.MenuId == menuId).FirstOrDefault(); EntityFile.MenuItems.Remove(ItemDetails); EntityFile.SaveChanges(); return(Json("Success", JsonRequestBehavior.AllowGet)); } catch { return(Json("Error", JsonRequestBehavior.AllowGet)); } }
public JsonResult Deletecust(int id) { try { Chatpata_dabbaEntities1 EntityFile = new Chatpata_dabbaEntities1(); var CustDetails = EntityFile.CustomerMasters.Where(q => q.CustId == id).OrderBy(q => q.FirstName).FirstOrDefault(); EntityFile.CustomerMasters.Remove(CustDetails); EntityFile.SaveChanges(); return(Json("Success", JsonRequestBehavior.AllowGet)); } catch { return(Json("Error", JsonRequestBehavior.AllowGet)); } }
public ActionResult PlaceOrder(FormCollection frm) { try { if (Session["MenuID"] == null) { return(RedirectToAction("Order")); } if (Session["UserID"] == null) { return(RedirectToAction("Index", "Home")); } var id = Convert.ToInt32(Session["UserID"]); var MenuId = Convert.ToInt32(Session["MenuID"]); Chatpata_dabbaEntities1 Entity = new Chatpata_dabbaEntities1(); OrderMaster order = new OrderMaster(); var email = Entity.CustomerMasters.Where(q => q.CustId == id).FirstOrDefault(); order.CustomerId = id; order.MenuId = Convert.ToInt32(Session["MenuID"]); order.Date = DateTime.Now; order.Status = "Pending"; order.Description = "abc"; order.Quantity = Convert.ToInt32(frm["Quantity"]); order.StartDate = Convert.ToDateTime(frm["StartDate"]); order.EndDate = Convert.ToDateTime(frm["EndDate"]); TimeSpan ts = order.EndDate - order.StartDate; var NoOfDays = Convert.ToDecimal(ts.Days) + 1; order.Tax = Convert.ToDecimal(10); order.Total = (Entity.MenuMasters.Where(q => q.Id == MenuId).Sum(q => q.Price)) * order.Quantity * NoOfDays; order.GrandTotal = order.Total + (order.Total * order.Tax / 100); order.DeliveryAddr = Convert.ToString(frm["Street"]) + "," + Convert.ToString(frm["Area"]) + "," + Convert.ToString(frm["Pincode"]); // order.PaymentMode = "COD"; Entity.OrderMasters.Add(order); Entity.SaveChanges(); Session["OrderID"] = order.OrderId; int ck = Mail.SendMail("Order Details", "Your Order is Placed successfully for Price of Rs." + order.GrandTotal + "Thanks for Order", email.EmailID); return(RedirectToAction("Payment")); // return Json("Success", JsonRequestBehavior.AllowGet); } catch (Exception e) { throw e; // return Json("Error", JsonRequestBehavior.AllowGet); } }
public ActionResult Addarea(FormCollection frm) { try { Chatpata_dabbaEntities1 EntityFile = new Chatpata_dabbaEntities1(); AreaMaster reg = new AreaMaster(); reg.Name = Convert.ToString(frm["Name"]); EntityFile.AreaMasters.Add(reg); EntityFile.SaveChanges(); return(RedirectToAction("Admin", "Admin")); } catch (Exception ex) { throw ex; } }
public ActionResult AddDriver(FormCollection frm) { try { if (Session["UserID"] == null) { return(RedirectToAction("Index", "Home")); } var id = Convert.ToInt32(Session["UserID"]); Chatpata_dabbaEntities1 EntityFile = new Chatpata_dabbaEntities1(); CustomerMaster reg = new CustomerMaster(); reg.Roleid = 2; reg.FirstName = Convert.ToString(frm["FName"]); reg.LastName = Convert.ToString(frm["LName"]); reg.Address1 = Convert.ToString(frm["Address1"]); reg.Address2 = Convert.ToString(frm["Address2"]); reg.Address3 = Convert.ToString(frm["Address3"]); reg.Pincode = Convert.ToString(frm["Pincode"]); reg.PhoneNo = Convert.ToString(frm["PhoneNo"]); //reg.Gender = ""; //reg.Birthdate = Convert.ToDateTime(frm["Birthdate"]); string[] dtarray = frm["Birthdate"].ToString().Split('/'); reg.Birthdate = Convert.ToDateTime("" + dtarray[1] + "/" + dtarray[0] + "/" + dtarray[2]); reg.EmailID = Convert.ToString(frm["EmailID"]); reg.Password = MD5Crypt.Encrypt(frm["Password"], "Dabba"); EntityFile.CustomerMasters.Add(reg); EntityFile.SaveChanges(); return(RedirectToAction("Admin", "Admin")); } catch (Exception ex) { throw ex; } }
public JsonResult DeleteItem(int id) { try { Chatpata_dabbaEntities1 EntityFile = new Chatpata_dabbaEntities1(); var ItemDetails = EntityFile.ItemMasters.Where(q => q.Id == id).FirstOrDefault(); var menuitem = EntityFile.MenuItems.Where(q => q.ItemId == id).FirstOrDefault(); EntityFile.ItemMasters.Remove(ItemDetails); if (menuitem != null) { EntityFile.MenuItems.Remove(menuitem); } EntityFile.SaveChanges(); return(Json("Success", JsonRequestBehavior.AllowGet)); } catch { return(Json("Error", JsonRequestBehavior.AllowGet)); } }
public ActionResult FeedbackEntry(FormCollection frm) { try { Chatpata_dabbaEntities1 Entity = new Chatpata_dabbaEntities1(); FeedbackMaster fbm = new FeedbackMaster(); fbm.Feedback = Convert.ToString(frm["Feedback"]); fbm.Date = DateTime.Now; fbm.CustId = Convert.ToInt16(Session["UserID"]); Entity.FeedbackMasters.Add(fbm); Entity.SaveChanges(); return(RedirectToAction("Customer")); } catch (Exception ex) { throw ex; } }
public ActionResult AddItem(FormCollection frm, HttpPostedFileBase file) { try { if (Session["UserID"] == null) { return(RedirectToAction("Index", "Home")); } var id = Convert.ToInt32(Session["UserID"]); Chatpata_dabbaEntities1 EntityFile = new Chatpata_dabbaEntities1(); ItemMaster im = new ItemMaster(); var newFileName = ""; if (file != null) { string pic = System.IO.Path.GetFileName(file.FileName); FileInfo fi = new FileInfo(pic); string fileextension = fi.Extension.Substring(1).ToUpper(); newFileName = Convert.ToString(Guid.NewGuid()) + "." + fileextension; var FolderPath = "~/Images/"; var Imgpath = Path.Combine(Server.MapPath(FolderPath), newFileName); file.SaveAs(Imgpath); newFileName = FolderPath + newFileName; } im.Name = Convert.ToString(frm["Name"]); im.Description = Convert.ToString(frm["Description"]); im.Image = Convert.ToString(frm["Image"]); im.Price = Convert.ToDecimal(frm["Price"]); im.Image = newFileName; EntityFile.ItemMasters.Add(im); EntityFile.SaveChanges(); return(RedirectToAction("Admin", "Admin")); } catch (Exception e) { throw e; } }
public ActionResult SampleOrder(int id) { try { Chatpata_dabbaEntities1 Entity = new Chatpata_dabbaEntities1(); RequestMaster rm = new RequestMaster(); var custid = Convert.ToInt32(Session["UserID"]); var chkOrder = Entity.RequestMasters.Where(q => q.CustId == custid).FirstOrDefault(); var email = Entity.CustomerMasters.Where(q => q.CustId == custid).FirstOrDefault(); if (chkOrder == null) { rm.CustId = Convert.ToInt32(Session["UserID"]); rm.MenuId = id; rm.Status = "Pending"; rm.Date = DateTime.Now; Entity.RequestMasters.Add(rm); Entity.SaveChanges(); int ck = Mail.SendMail("Sample-tiffin", "Your Order for sample tiffin is registered", email.EmailID); TempData["notice"] = "Your Order for sample tiffin is successfully registerd"; Session["ReqmenuId"] = rm.MenuId; return(RedirectToAction("ViewReqStasus")); } else // (chkOrder.Status == "A") { // if (chkOrder.Status == "Accept" || chkOrder.Status == "Reject") //{ TempData["notice"] = "You are alerdy oredred for sample tiffin"; rm.MenuId = id; Session["ReqmenuId"] = rm.MenuId; return(RedirectToAction("ViewReqStasus", "Customer")); // } } } catch (Exception ex) { throw ex; } }
public ActionResult GenerateDispatch() { try { if (Session["UserID"] == null) { return(RedirectToAction("Index", "Home")); } Chatpata_dabbaEntities1 Entity1 = new Chatpata_dabbaEntities1(); var entry = Entity1.DailyOrders.Where(q => q.Date.Day == DateTime.Now.Day && q.Date.Month == DateTime.Now.Month).ToList(); foreach (var order in entry.ToList()) { var co = Convert.ToDecimal(0); if (order.Code == co) { var myrand = new Random(); var c = Convert.ToDecimal(myrand.Next(100000, 1000000)); order.Code = c; Entity1.Entry(order).State = System.Data.Entity.EntityState.Modified; Entity1.SaveChanges(); var mailid = order.CustomerMaster.EmailID; int ck = Mail.SendMail("Today's Code for you", "Code:" + c + "\n have a nice food..", mailid); } } return(RedirectToAction("ViewDailyOrder")); } catch (Exception e) { throw e; } }
public ActionResult AddUser(FormCollection frm, HttpPostedFileBase file) { try { Chatpata_dabbaEntities1 EntityFile = new Chatpata_dabbaEntities1(); CustomerMaster reg = new CustomerMaster(); reg.Roleid = 3; reg.FirstName = Convert.ToString(frm["FName"]); reg.LastName = Convert.ToString(frm["LName"]); reg.Address1 = Convert.ToString(frm["Address1"]); reg.Address2 = Convert.ToString(frm["Address2"]); reg.Address3 = Convert.ToString(frm["Address3"]); reg.Pincode = Convert.ToString(frm["Pincode"]); reg.PhoneNo = Convert.ToString(frm["PhoneNo"]); if (Convert.ToString(frm["gender"]) == "male") { reg.Gender = "Male"; } else { reg.Gender = "Female"; } var newFileName = ""; if (file != null) { string pic = System.IO.Path.GetFileName(file.FileName); FileInfo fi = new FileInfo(pic); string fileextension = fi.Extension.Substring(1).ToUpper(); newFileName = Convert.ToString(Guid.NewGuid()) + "." + fileextension; var FolderPath = "~/Images/"; var Imgpath = Path.Combine(Server.MapPath(FolderPath), newFileName); file.SaveAs(Imgpath); newFileName = FolderPath + newFileName; } reg.Image = Convert.ToString(frm["Image"]); reg.Image = newFileName; string[] dtarray = frm["Birthdate"].ToString().Split('/'); reg.Birthdate = Convert.ToDateTime("" + dtarray[1] + "/" + dtarray[0] + "/" + dtarray[2]); reg.EmailID = Convert.ToString(frm["EmailID"]); reg.Password = MD5Crypt.Encrypt(frm["Password"], "Dabba"); reg.QuestionID = Convert.ToInt32(frm["AID"]); reg.Answer = frm["Answer"]; EntityFile.CustomerMasters.Add(reg); EntityFile.SaveChanges(); int chkmail = Mail.SendMail("Registration", "Thanks", reg.EmailID); // TempData["msg"] = "Your are successfully registered , please login in to website for further details"; return(RedirectToAction("Index", "Home")); } catch (Exception ex) { throw ex; } }