public IActionResult AddEmployee() { Employee e = new Employee(); firstappContext d = new firstappContext(); e.EmployeeName = HttpContext.Request.Form["cname"].ToString(); e.EmployeePosition = HttpContext.Request.Form["Position"].ToString(); e.PhoneNumber = Convert.ToInt32(HttpContext.Request.Form["phone"]); e.Email = HttpContext.Request.Form["email"].ToString(); e.Salary = Convert.ToDouble(HttpContext.Request.Form["Salary"]); var regex = new Regex(@"[0-9]{10}"); var regex1 = new Regex(@"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$"); var regex2 = new Regex(@"^[a-zA-Z]+$"); if (regex.IsMatch(e.PhoneNumber.ToString()) && regex1.IsMatch(e.Email) && regex2.IsMatch(e.EmployeeName)) { d.Employee.Add(e); d.SaveChanges(); ViewData["Message"] = "Successfully added"; } else { ViewData["Message"] = "Enter correctly"; } return(View()); }
public IActionResult AddVendor() { Vendor e = new Vendor(); firstappContext d = new firstappContext(); e.VendorName = HttpContext.Request.Form["cname"].ToString(); e.PhoneNumber = Convert.ToInt64(HttpContext.Request.Form["phone"]); e.Email = HttpContext.Request.Form["email"].ToString(); e.JoinDate = Convert.ToDateTime(HttpContext.Request.Form["Date"]); var regex = new Regex(@"[0-9]{10}"); var regex1 = new Regex(@"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$"); var regex2 = new Regex(@"^[a-zA-Z]+$"); if (regex.IsMatch(e.PhoneNumber.ToString()) && regex1.IsMatch(e.Email) && regex2.IsMatch(e.VendorName)) { d.Vendor.Add(e); d.SaveChanges(); ViewData["Message"] = "Successfully added"; } else { ViewData["Message"] = "Enter correctly"; } return(View()); }
public IActionResult AddQuery() { firstappContext b = new firstappContext(); Queries d = new Queries(); var ProductName = HttpContext.Request.Form["pname"].ToString(); var CustomerName = HttpContext.Request.Form["cname"].ToString(); var ProductId = Convert.ToInt32((from s in b.Product where s.ProductName == ProductName select s.ProductId).FirstOrDefault()); var CustomerId = Convert.ToInt32((from s in b.Customer where s.CustomerName == CustomerName select s.CustomerId).FirstOrDefault()); var OrderId = Convert.ToInt32((from s in b.ProductOrder where s.ProductId == ProductId && s.CustomerId == CustomerId select s.OrderId).FirstOrDefault()); var query = HttpContext.Request.Form["query"].ToString(); if (OrderId != 0 && CustomerId != 0 && ProductId != 0) { d.Cquery = query; d.EmployeeId = 1; d.OrderId = OrderId; d.Qstatus = "Registered"; b.Add(d); b.SaveChanges(); ViewData["Message"] = "Query registered successfully"; } else { ViewData["Message"] = "Invalid details"; } return(View()); }
public IActionResult AddProduct() { Product p = new Product(); firstappContext c = new firstappContext(); p.ProductName = HttpContext.Request.Form["pname"].ToString(); p.Price = Convert.ToDouble(HttpContext.Request.Form["price"]); p.ProductDescription = HttpContext.Request.Form["Description"].ToString(); p.Category = HttpContext.Request.Form["Category"].ToString(); c.Add(p); c.SaveChanges(); return(View()); }
public IActionResult AddProduct() { Product p = new Product(); firstappContext c = new firstappContext(); string pname = HttpContext.Request.Form["pname"].ToString(); p.ProductName = HttpContext.Request.Form["pname"].ToString(); p.Price = Convert.ToDouble(HttpContext.Request.Form["price"]); p.ProductDescription = HttpContext.Request.Form["Description"].ToString(); p.Category = HttpContext.Request.Form["Category"].ToString(); c.Add(p); c.SaveChanges(); Inventory d = new Inventory(); var Pid = Convert.ToInt32((from s in c.Product where s.ProductName == pname select s.ProductId).FirstOrDefault()); d.Quantity = 10; d.Stock = 1; d.ProductId = Pid; c.Add(d); c.SaveChanges(); return(View()); }
public IActionResult Contact() { Customer a = new Customer(); Address c = new Address(); firstappContext b = new firstappContext(); a.CustomerName = HttpContext.Request.Form["cname"].ToString(); ViewData["customer"] = a.CustomerName; a.PhoneNumber = Convert.ToInt64(HttpContext.Request.Form["phone"]); a.Email = HttpContext.Request.Form["email"].ToString(); a.JoinDate = Convert.ToDateTime(HttpContext.Request.Form["Date"]); var regex = new Regex(@"[0-9]{10}"); var regex1 = new Regex(@"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$"); var regex2 = new Regex(@"^[a-zA-Z]+$"); if (regex.IsMatch(a.PhoneNumber.ToString()) && regex1.IsMatch(a.Email) && regex2.IsMatch(a.CustomerName)) { b.Customer.Add(a); b.SaveChanges(); ViewData["Message"] = "Successfully added"; } else { ViewData["Message"] = "Enter correctly"; } var cus = Convert.ToInt32((from s in b.Customer where (s.CustomerName == a.CustomerName && s.PhoneNumber == a.PhoneNumber) select s.CustomerId).FirstOrDefault()); //get the last record inserted id c.CustomerId = cus; c.City = HttpContext.Request.Form["city"].ToString(); c.State = HttpContext.Request.Form["state"].ToString(); c.Address1 = HttpContext.Request.Form["address"].ToString(); b.Address.Add(c); b.SaveChanges(); ViewData["Message"] = "Successfully added"; return(View()); }
public IActionResult AddOrder() { Customer a = new Customer(); Product b = new Product(); ProductOrder c = new ProductOrder(); Bill e = new Bill(); Cart f = new Cart(); Delivery g = new Delivery(); string CustomerName = HttpContext.Request.Form["cname"].ToString(); string ProductName = HttpContext.Request.Form["pname"].ToString(); firstappContext d = new firstappContext(); var Customer_Id = Convert.ToInt32((from s in d.Customer where s.CustomerName == CustomerName select s.CustomerId).FirstOrDefault()); var Product_Id = Convert.ToInt32((from s in d.Product where s.ProductName == ProductName select s.ProductId).FirstOrDefault()); if (Customer_Id != 0 || Product_Id != 0) { c.CustomerId = Customer_Id; c.ProductId = Product_Id; c.OrderStatus = "Ordered"; string payment = HttpContext.Request.Form["payment"].ToString(); if (payment == "Online") { c.OrderPaymentStatus = "Paid Online"; d.Add(c); d.SaveChanges(); var OrderId = Convert.ToInt32((from s in d.ProductOrder orderby s.OrderId descending select s.OrderId).FirstOrDefault()); g.OrderId = OrderId; var Addres = Convert.ToInt32((from s in d.Address where s.CustomerId == Customer_Id select s.AddressId).FirstOrDefault()); g.AddressId = Addres; g.DeliveryStatus = "Dispatched"; g.PaymentStatus = "Paid"; g.EmployeeId = 1; d.Add(g); d.SaveChanges(); } else { c.OrderPaymentStatus = "To be paid during delivery"; d.Add(c); d.SaveChanges(); var OrderId = Convert.ToInt32((from s in d.ProductOrder orderby s.OrderId descending select s.OrderId).FirstOrDefault()); g.OrderId = OrderId; var Addres = Convert.ToInt32((from s in d.Address where s.CustomerId == Customer_Id select s.AddressId).FirstOrDefault()); g.AddressId = Addres; g.DeliveryStatus = "Dispatched"; g.PaymentStatus = "To be collected at site"; g.EmployeeId = 1; d.Add(g); d.SaveChanges(); } var Order_Id = Convert.ToInt32((from s in d.ProductOrder orderby s.OrderId descending select s.OrderId).FirstOrDefault()); f.OrderId = Order_Id; f.ProductId = Product_Id; d.Add(f); d.SaveChanges(); ViewData["Message"] = "Order successfully placed"; } else { ViewData["Message"] = "Invalid customer name or product name"; } return(View()); }