public ActionResult Register(CustomerDomain model) { try { if (ModelState.IsValid) { // TO DO CustomerCRUD.AddToCustomer(model); return(View()); } return(View("Registered")); } catch (Exception ex) { ExceptionLogDomain obj = new ExceptionLogDomain(); obj.MethodName = "Register"; obj.ControllerName = "Customer"; obj.ErrorText = ex.Message; obj.StackTrace = ex.StackTrace; obj.Datetime = DateTime.Now; ExceptionLogCRUD.AddToExceptionLog(obj); return(RedirectToAction("Index", "Error")); } }
public ListsViewModel() { BorrowBookCommand = new DelegateCommand(BorrowBook); BookAddCommand = new DelegateCommand(BookAdd); CustomerAddCommand = new DelegateCommand(CustomerAdd); CustomerSaveCommand = new DelegateCommand(CustomerSave); BookSaveCommand = new DelegateCommand(BookSave); BookViewCommand = new DelegateCommand(BookView); BookDeleteCommand = new DelegateCommand(BookDelete); BookEditCommand = new DelegateCommand(BookEdit); CustomerViewCommand = new DelegateCommand(CustomerView); CustomerDeleteCommand = new DelegateCommand(CustomerDelete); CustomerEditCommand = new DelegateCommand(CustomerEdit); ViewCommand = new DelegateCommand(ViewDetails); ReturnBookCommand = new DelegateCommand(ReturnBook); EditReturnDateCommand = new DelegateCommand(EditReturnDate); b = GetBooks()[1]; int _id = CustomerCRUD.getMaxId() + 1; customer = new Customer(_id, "name", 0); int _id2 = BookCRUD.getMaxId() + 1; book = new Book(_id2, "title", "author", "type", 0, DateTime.Today, 0); }
public ActionResult Login(CustomerModel model) { try { var result = CustomerCRUD.CustomerLogin(model.Email, model.Password); if (result.Count() > 0) { Session["FullName"] = result[0].FirstName + " " + result[0].LastName; Session["idUser"] = result[0].Id; return(RedirectToAction("Index", "Menu")); } else { ViewBag.error = "Login failed"; return(View()); } } catch (Exception ex) { ExceptionLogDomain obj = new ExceptionLogDomain(); obj.MethodName = "Login"; obj.ControllerName = "Customer"; obj.ErrorText = ex.Message; obj.StackTrace = ex.StackTrace; obj.Datetime = DateTime.Now; ExceptionLogCRUD.AddToExceptionLog(obj); return(RedirectToAction("Index", "Error")); } }
public ActionResult MyAccount() { int custid = Convert.ToInt32(Session["idUser"]); if (custid != 0) { var CustomerDetails = CustomerCRUD.GetCustomerById(Convert.ToInt32(Session["idUser"])); CustomerDomain Customer = new CustomerDomain(); Customer.Id = CustomerDetails[0].Id; Customer.FirstName = CustomerDetails[0].FirstName; Customer.LastName = CustomerDetails[0].LastName; Customer.Email = CustomerDetails[0].Email; Customer.Phone = CustomerDetails[0].Phone; Customer.Country = CustomerDetails[0].Country; Customer.State = CustomerDetails[0].State; Customer.City = CustomerDetails[0].City; Customer.Pincode = CustomerDetails[0].Pincode; Customer.ShippingAddress = CustomerDetails[0].ShippingAddress; Customer.BillingAddress = CustomerDetails[0].BillingAddress; return(View(Customer)); } else { return(RedirectToAction("Login", "Customer")); } }
static async Task Main(string[] args) { var productRepo = new ProductCRUD(); var customerRepo = new CustomerCRUD(); var orderRepo = new OrderCRUD(); var userModels = db.Get(); }
public void AddCustomerToDatabase() { Customers c = new Customers() { id = 101, name = "Paul", money = 100 }; Assert.IsTrue(CustomerCRUD.addCustomer(c.id, c.name, c.money)); }
public void DeleteCustomerFromDatabase() { Customers c = new Customers() { id = 102, name = "Paul", money = 100 }; Assert.IsTrue(CustomerCRUD.addCustomer(c.id, c.name, c.money)); Assert.IsTrue(CustomerCRUD.removeCustomer(c.id)); }
public ObservableCollection <Customer> GetCustomers() { customers = new ObservableCollection <Customer>(); for (int i = 1; i <= CustomerCRUD.getMaxId(); i++) { Customer c = new Customer(i); if (c.Name != null) { customers.Add(c); } } return(customers); }
public void AddCustomer() { bool added = CustomerCRUD.addCustomer(newCustomer.customer_id, newCustomer.customer_f_name, newCustomer.customer_l_name); if (added) { actionText = "Customer Added"; } else { actionText = "Customer with such ID already exists in the database"; } MessageBoxShowDelegate(ActionText); }
public ActionResult ChangePassword(string password) { int custid = Convert.ToInt32(Session["idUser"]); if (custid != 0) { var result = CustomerCRUD.UpdateCustomerPassword(custid, password); return(Json(result)); } else { return(RedirectToAction("Login")); } }
public void EditCustomer() { bool editedN = CustomerCRUD.updateName(currentCustomer.customer_id, currentCustomer.customer_f_name); bool editedF = CustomerCRUD.updateLastName(currentCustomer.customer_id, currentCustomer.customer_l_name); if (editedN && editedF) { actionText = "Customer Edited"; } else { actionText = "Oh nooo something went wrong"; } MessageBoxShowDelegate(ActionText); }
// GET: CustomerDashbord public ActionResult Index() { int custid = Convert.ToInt32(Session["idUser"]); if (custid != 0) { var CustomerDetails = CustomerCRUD.GetCustomerById(custid); return(View(CustomerDetails)); } else { return(RedirectToAction("Login", "Customer")); } }
public JsonResult ChkEmailExistsOrNot(string emailId) { try { var result = CustomerCRUD.ChkEmailExistsOrNot(emailId); return(Json(result)); } catch (Exception ex) { ExceptionLogDomain obj = new ExceptionLogDomain(); obj.MethodName = "ChkEmailExistsOrNot"; obj.ControllerName = "Customer"; obj.ErrorText = ex.Message; obj.StackTrace = ex.StackTrace; obj.Datetime = DateTime.Now; ExceptionLogCRUD.AddToExceptionLog(obj); return(Json(false)); } }
public Customer(int _id) { CustomerId = _id; Name = CustomerCRUD.getName(_id); Money = CustomerCRUD.getMoney(_id); }