public ActionResult AddOrEdit(BKRY_CATEGORY bkt, HttpPostedFileBase file) { try { byte[] buf = null; if (file != null && file.ContentLength > 0) { buf = new byte[file.ContentLength]; file.InputStream.Read(buf, 0, buf.Length); bkt.image = buf; } bkt.insert_by = Session != null && Session["UserName"] != null ? Session["UserName"].ToString() : ""; bkt.add_date = DateTime.Now; using (BKRY_MNGT_SYSEntities db = new BKRY_MNGT_SYSEntities()) { if (bkt.Id == 0) { db.BKRY_CATEGORY.Add(bkt); db.SaveChanges(); return(RedirectToAction("Index")); } else { db.Entry(bkt).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } return(null); }
public ActionResult AddOrEdit(BKRY_ITEMS bkt, HttpPostedFileBase file) { byte[] buf = null; if (file != null && file.ContentLength > 0) { buf = new byte[file.ContentLength]; file.InputStream.Read(buf, 0, buf.Length); bkt.image = buf; } bkt.insert_by = Session != null && Session["UserName"] != null ? Session["UserName"].ToString() : ""; bkt.add_date = DateTime.Now; bkt.categoryId = Convert.ToInt64(Request.Form["categoryname"] != "" ? Request.Form["categoryname"] : "0"); using (BKRY_MNGT_SYSEntities db = new BKRY_MNGT_SYSEntities()) { if (bkt.Id == 0) { db.BKRY_ITEMS.Add(bkt); db.SaveChanges(); return(RedirectToAction("Index")); } else { db.Entry(bkt).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbEntityValidationException e) { throw e; } return(RedirectToAction("Index")); } } }
public ActionResult Delete(int id) { using (BKRY_MNGT_SYSEntities db = new BKRY_MNGT_SYSEntities()) { BKRY_ITEMS emp = db.BKRY_ITEMS.Where(x => x.Id == id).FirstOrDefault <BKRY_ITEMS>(); db.BKRY_ITEMS.Remove(emp); db.SaveChanges(); return(Json(new { success = true, message = "Deleted Successfully" }, JsonRequestBehavior.AllowGet)); } }
public JsonResult DeleteUser(string id) { using (BKRY_MNGT_SYSEntities db = new BKRY_MNGT_SYSEntities()) { var search = db.SYS_USR_INFO.ToList().Where(x => x.UserId == Convert.ToInt32(id)).FirstOrDefault(); db.SYS_USR_INFO.Remove(search); db.SaveChanges(); return(Json(new { success = true, message = "Deleted Successfully" }, JsonRequestBehavior.AllowGet)); } }
public ActionResult CreateFeedback() { using (db = new BKRY_MNGT_SYSEntities()) { CUST_FEED obj = new CUST_FEED(); obj.Customer_ID = null; obj.Order_id = Session["Order"].ToString(); obj.feedback = Request.Form["feedback"].ToString(); obj.Creation_Id = DateTime.Now.ToShortDateString(); db.CUST_FEED.Add(obj); db.SaveChanges(); } Session["Message"] = null; Session["Order"] = null; return(RedirectToAction("Index", "Home")); }
public static void startDeliveryFunction() { List <BKRY_DELIVERY> bkryList = null; using (BKRY_MNGT_SYSEntities db = new BKRY_MNGT_SYSEntities()) { bkryList = db.BKRY_DELIVERY.Where(x => x.DeliveryStatus == null || x.DeliveryStatus == oldstatus).ToList <BKRY_DELIVERY>(); foreach (var item in bkryList) { item.DeliveryStatus = status; } db.SaveChanges(); } if (Helper.status == 3) { oldstatus = -1; status = 0; } else { oldstatus = status; status += 1; } }
public ActionResult CreateOrder() { List <BKRY_ITEMS> bkryList = new List <BKRY_ITEMS>(); if (Session != null && Session["Cart"] != null && ((List <int>)Session["Cart"]).Count > 0) { List <int> itemids = ((List <int>)Session["Cart"]); using (BKRY_MNGT_SYSEntities db = new BKRY_MNGT_SYSEntities()) { bkryList = db.BKRY_ITEMS.Where(x => itemids.Contains(x.Id)).ToList <BKRY_ITEMS>(); foreach (BKRY_ITEMS item in bkryList) { item.image = null; item.quantity = itemids.GroupBy(i => i).Where(x => x.Key == item.Id).FirstOrDefault().Count(); } } } try { using (BKRY_MNGT_SYSEntities db = new BKRY_MNGT_SYSEntities()) { BKRY_ORDER obj = new BKRY_ORDER(); obj.OrderDetails = JsonConvert.SerializeObject(bkryList); obj.personname = Request["name"].ToString(); obj.phone = Request["phone"].ToString(); obj.email = Request["email"].ToString(); obj.address = Request["address"].ToString(); obj.street = Request["street"].ToString(); obj.postCode = Request["postcode"].ToString(); obj.inserted_dt = DateTime.Now; db.BKRY_ORDER.Add(obj); db.SaveChanges(); Session["Cart"] = null; BKRY_DELIVERY dobj = new BKRY_DELIVERY(); dobj.OrderDetails = JsonConvert.SerializeObject(bkryList); dobj.OrderId = obj.Id; dobj.inserted_dt = DateTime.Now; dobj.DeliveryStatus = 0; dobj.PaymentType = Convert.ToInt16(Request.Form["nm_rad_pay"]); if (dobj.PaymentType == 1) { BKRY_CREDITCARDINFO objC = new BKRY_CREDITCARDINFO(); objC.OrderID = obj.Id; objC.cardname = Request["cardname"].ToString(); objC.cardnumber = Request["cardnumber"].ToString(); objC.expyear = Request["expyear"].ToString(); objC.cvv = Request["cvv"].ToString(); objC.expmonth = " "; db.BKRY_CREDITCARDINFO.Add(objC); } db.BKRY_DELIVERY.Add(dobj); db.SaveChanges(); Session["Message"] = "Saved Successfully your Order# is " + obj.Id.ToString(); Session["Order"] = obj.Id; return(RedirectToAction("Index", "home")); } } catch (Exception ex) { return(Json(new { success = true, message = "UnSuccessfully" }, JsonRequestBehavior.AllowGet)); } }
public ActionResult CreateUser(SYS_USR_INFO objOn) { string ipAddress = Request.ServerVariables["HTTP_X_FORWARDED_FOR"]; if (string.IsNullOrEmpty(ipAddress)) { ipAddress = Request.ServerVariables["REMOTE_ADDR"]; } Dictionary <string, string> osList = new Dictionary <string, string> { { "Windows NT 6.3", "Windows 8.1" }, { "Windows NT 6.2", "Windows 8" }, { "Windows NT 6.1", "Windows 7" }, { "Windows NT 6.0", "Windows Vista" }, { "Windows NT 5.2", "Windows Server 2003" }, { "Windows NT 5.1", "Windows XP" }, { "Windows NT 5.0", "Windows 2000" } }; string userAgentText = Request.UserAgent; string osVersion = ""; if (userAgentText != null) { int startPoint = userAgentText.IndexOf('(') + 1; int endPoint = userAgentText.IndexOf(';'); osVersion = userAgentText.Substring(startPoint, (endPoint - startPoint)); //string friendlyOsName = osList[osVersion]; } SYS_USR_INFO userinfo = new SYS_USR_INFO(); try { using (BKRY_MNGT_SYSEntities db = new BKRY_MNGT_SYSEntities()) { SYS_USR_INFO obj = new SYS_USR_INFO { UserId = (objOn.UserId > 0) ? objOn.UserId : 0, UserName = objOn.UserName, UserPassowrd = objOn.UserPassowrd, MachineIP = ipAddress, OperatingSystem = osVersion, LoginTime = DateTime.Now, LoginErrorMessage = JsonConvert.SerializeObject(userinfo), address = objOn.address, email = objOn.email, street = objOn.street, phone = objOn.phone, postCode = objOn.postCode }; if (db.SYS_USR_INFO.Where(x => x.UserName == obj.UserName).ToList().Count == 0) { db.SYS_USR_INFO.Add(obj); db.Entry(obj).State = EntityState.Added; db.SaveChanges(); Session["Message"] = "Saved Successfully your UserName# is " + obj.UserName.ToString(); } else { db.SYS_USR_INFO.Remove(db.SYS_USR_INFO.Where(x => x.UserName == obj.UserName).ToList().FirstOrDefault()); db.SYS_USR_INFO.Add(obj); db.SaveChanges(); Session["Message"] = "Updated Successfully your UserName# is " + obj.UserName.ToString(); } return(RedirectToAction("LogOut", "Login")); } } catch (Exception ex) { return(Json(new { success = true, message = "UnSuccessfully" + ex.ToString() }, JsonRequestBehavior.AllowGet)); } }
public ActionResult Autherize(BakerySystem.Models.SYS_USR_INFO userModel) { string ipAddress = Request.ServerVariables["HTTP_X_FORWARDED_FOR"]; if (string.IsNullOrEmpty(ipAddress)) { ipAddress = Request.ServerVariables["REMOTE_ADDR"]; } Dictionary <string, string> osList = new Dictionary <string, string> { { "Windows NT 6.3", "Windows 8.1" }, { "Windows NT 6.2", "Windows 8" }, { "Windows NT 6.1", "Windows 7" }, { "Windows NT 6.0", "Windows Vista" }, { "Windows NT 5.2", "Windows Server 2003" }, { "Windows NT 5.1", "Windows XP" }, { "Windows NT 5.0", "Windows 2000" } }; string userAgentText = Request.UserAgent; string osVersion = ""; if (userAgentText != null) { int startPoint = userAgentText.IndexOf('(') + 1; int endPoint = userAgentText.IndexOf(';'); osVersion = userAgentText.Substring(startPoint, (endPoint - startPoint)); //string friendlyOsName = osList[osVersion]; SYS_USR_INFO info = new SYS_USR_INFO() { MachineIP = ipAddress, OperatingSystem = osVersion }; } if ("admin" == userModel.UserName && "admin" == userModel.UserPassowrd) { Session["userID"] = "1"; Session["userName"] = "******"; Session["ltype"] = "1"; return(View("~/Views/adminPanel/Index.cshtml")); } else { using (BKRY_MNGT_SYSEntities db = new BKRY_MNGT_SYSEntities()) { var userDetails = db.SYS_USR_INFO.Where(x => x.UserName == userModel.UserName && x.UserPassowrd == userModel.UserPassowrd).FirstOrDefault(); if (userDetails == null) { userModel.LoginErrorMessage = "Wrong username or password."; return(View("Index", userModel)); } else { Session["userID"] = userDetails.UserId; Session["userName"] = userDetails.UserName; Session["ltype"] = "2"; LoginDetail ld = new LoginDetail(); ld.UserId = userDetails.UserId; ld.UserName = userDetails.UserName; ld.OperatingSystem = osVersion; ld.MachineIP = ipAddress; ld.UserPassowrd = userDetails.UserPassowrd; ld.LoginTime = DateTime.Now; db.LoginDetails.Add(ld); db.SaveChanges(); return(RedirectToAction("Index", "Home")); } } } }