public static bool Register(Model.Customer customer) { customer.Account = new Model.CustomerAccount(); customer.Account.Amount = 100M; return(CustomerDAL.Register(customer)); }
public ActionResult Login(LoginModel model) { if (ModelState.IsValid) { var dal = new CustomerDAL(); var result = dal.Login(model.UserName, Encryptor.MD5Hash(model.Password)); if (result == 1) { var _cusUser = dal.GetByEmail(model.UserName); var cusUserSession = new CusUserLogin(); cusUserSession.CustomerEmail = _cusUser.CustomerEmail; cusUserSession.CustomerName = _cusUser.CustomerName; cusUserSession.CustomerID = _cusUser.CustomerID; Session.Add(CommonConstants.CusUserSession, cusUserSession); return(Redirect("/")); } else if (result == 0) { ModelState.AddModelError("", "Tài khoản không tồn tại."); } else if (result == -1) { ModelState.AddModelError("", "Tài khoản đang bị khoá."); } else if (result == -2) { ModelState.AddModelError("", "Mật khẩu không đúng."); } else { ModelState.AddModelError("", "đăng nhập không đúng."); } } return(View(model)); }
public ActionResult UpdateAccount(User model) { model = new CustomerDAL().Update(model); if (model.Status > 0) { ViewBag.ErrorMessage = model.Message; return(View("Dashboard", model)); } else { FormsAuthentication.SignOut(); Session["UserSession"] = model.UserName; var serializer = new JavaScriptSerializer(); string userData = serializer.Serialize(model); FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, model.UserName, DateTime.Now, DateTime.Now.AddHours(8), true, userData, FormsAuthentication.FormsCookiePath); // Encrypt the ticket. string encTicket = FormsAuthentication.Encrypt(ticket); // Create the cookie. HttpContext.Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, encTicket)); return(RedirectToAction("Dashboard")); } }
public List <CatagoryType> GetCategoryType(string filter) { ICustomerDAL customerDAL = new CustomerDAL(); List <CatagoryType> result = customerDAL.GetCategoryType(filter); return(result); }
public List <Customer> GetAll() { CustomerDAL dal = new CustomerDAL(); var customers = dal.GetAll(); return(customers); }
public string GetCustomerList() { CustomerDAL dalCustomer = new CustomerDAL(); DataTransfer response = dalCustomer.GetCustomerList(); return(JSonHelper.ConvertObjectToJSon(response)); }
/// <summary> /// Gets all customer. /// </summary> /// <returns>Get All Customer</returns> public List <Customer> GetAllCustomer() { ICustomerDAL customerDAL = new CustomerDAL(); List <Customer> result = customerDAL.GetAllCustomer(); return(result); }
//skapa / uppdatera kund public void SaveCustomer(Customer customer) { //Här samlas alla valideringsfel ICollection <ValidationResult> validationResults; //Om valideringen inte är godkänd if (!customer.Validate(out validationResults)) { //Ett undantag kastas och alla felmeddelanden följer med var ex = new ValidationException("Kunden klarade inte valideringen."); ex.Data.Add("ValidationResults", validationResults); throw ex; } //ny kund (skickar tillbaka customerID) if (customer.CustomerID == 0) { CustomerDAL.NewCustomer(customer); } //uppdaterad kund (skickar tillbaka antal ändrade rader) else { CustomerDAL.UpdateCustomer(customer); } }
public bool AddCustomerBL(Customer objAddCustomer) { bool CustomerAdded = false; try { if (ValidateAddCustomer(objAddCustomer)) { CustomerDAL customerDAL = new CustomerDAL(); CustomerAdded = customerDAL.RegistrationCustomerDAL(objAddCustomer); } else { throw new RecipeIngredientSystemExceptions("All fields mandatory!"); } } //catch (IngredientsRecipeShoppingExceptions) //{ // throw; //} catch (RecipeIngredientSystemExceptions) { throw; } catch (Exception ex) { throw ex; } return(CustomerAdded); }
public static List <int> GetIds() { List <int> Ids = null; Ids = CustomerDAL.GetIds(); return(Ids); }
public static List <string> GetCities(string country) { List <string> str = null; str = CustomerDAL.GetCities(country); return(str); }
public static bool DeleteCustomerBL(int deleteCustomerId) { bool customerDeleted = false; try { if (deleteCustomerId > 0) { CustomerDAL customerDAL = new CustomerDAL(); customerDeleted = customerDAL.DeleteCustomerDAL(deleteCustomerId); } else { throw new CustomerException("Invalid Customer Id"); } } catch (CustomerException) { throw; } catch (Exception ex) { throw ex; } return(customerDeleted); }
public static bool Insert(Customer cust) { bool status = false; status = CustomerDAL.Insert(cust); return(status);//Query Processing }
public void AddToShoppingCartTest2(int amount) { Order order = new Order(); CustomerDAL customerDAL = new CustomerDAL(); order.OrderUser = new Customer(); Shoes item = new Shoes(); order.OrderItem = new Shoes(); order.OrderUser.UserID = 1; order.OrderItem.ShoesId = null; MySqlCommand command = DBHelper.OpenConnection().CreateCommand(); command.CommandText = $"insert into Orders(order_customer,order_status) values ({order.OrderUser.UserID},0)"; command.ExecuteNonQuery(); customerDAL.UpdateStatusShoppingCartById(false, order.OrderUser.UserID); // set userShopping cart to 1 Assert.False(orderDAL.AddToShoppingcart(order, amount)); orderDAL.DeleteAllItemInShoppingCartByUserID(order.OrderUser.UserID); customerDAL.UpdateStatusShoppingCartById(true, order.OrderUser.UserID); // set userShopping cart to 0 }
public List<Customer> GetCustomers() { List<Customer> customerList = new List<Customer>(); CustomerDAL customerDAL = new CustomerDAL(); customerList = customerDAL.GetCustomers(); return customerList; }
public bool CustomerLoginBL(Customer objLoginCustomer) { bool Login = false; try { if (ValidateCustomer(objLoginCustomer)) { CustomerDAL customerDAL = new CustomerDAL(); Login = customerDAL.CustomerLoginDAL(objLoginCustomer); } else { throw new RecipeIngredientSystemExceptions("Incorrect Username or Password"); } } catch (RecipeIngredientSystemExceptions) { throw; } catch (Exception ex) { throw ex; } return(Login); }
public Customer login(Customer Customer) { var CustomerDAL = new CustomerDAL(); var loggedIn = CustomerDAL.login(Customer); return(loggedIn); }
public bool CustomerChangePaasBL(Customer objchangepassCustomer) { bool pass = false; try { if (ValidateChangePassCustomer(objchangepassCustomer)) { CustomerDAL adminDAL = new CustomerDAL(); pass = adminDAL.CustomerChangPassDAL(objchangepassCustomer); } else { throw new RecipeIngredientSystemExceptions("Please fill all details Correctly"); } } catch (RecipeIngredientSystemExceptions) { throw; } catch (Exception ex) { throw ex; } return(pass); }
//Test URL: https://localhost:44398/Test/PaginationCategory?page=1&pageSize=10&searchValue= /// <summary> /// Hiển thị list khách hàng, tìm kiếm và phân trang /// </summary> /// <param name="page"></param> /// <param name="pageSize"></param> /// <param name="searchValue"></param> /// <returns></returns> public ActionResult PaginationCustomer(int page, int pageSize, string searchValue) { string connectionString = ConfigurationManager.ConnectionStrings["LiteCommerceDB"].ConnectionString; ICustomerDAL dal = new CustomerDAL(connectionString); //var data = dal.List(page, pageSize, searchValue); //var data = dal.Count(""); //var data = dal.Delete(95); // var data = dal.Get(2); //return Json(data, JsonRequestBehavior.AllowGet); Customer data = new Customer() { CustomerID = 96, CustomerName = "Huỳnh Hải Hòa", ContactName = "Hòa Minzy hihi", Address = "Tam Sơn Núi Thành Quảng Nam", PostalCode = "5039", Country = "Việt Nam", City = "Quảng Nam", Email = "*****@*****.**", Password = "******" }; return(Json(dal.Update(data), JsonRequestBehavior.AllowGet)); }
private void m_GetCustomerListTestButton_Click(object sender, EventArgs e) { CustomerDAL dal = new CustomerDAL(); CustomerList list = dal.GetAllCustomers(); MessageBox.Show("Records returned : " + list.Count.ToString()); }
public List <CatagoryType> GetCustomerType() { ICustomerDAL customerDAL = new CustomerDAL(); List <CatagoryType> result = customerDAL.GetCustomerType(); return(result); }
public ActionResult Create([Bind(Include = "CustomerName")] CustomerDTO customerDTO) { IUnitOfWork database = new EFUnitOfWork(); var customer = new CustomerDAL { CustomerName = customerDTO.CustomerName, Id = customerDTO.Id }; try { if (ModelState.IsValid) { database.Customers.Insert(customer); database.Customers.Save(); return(RedirectToAction("Index")); } } catch (DataException /* dex */) { //Log the error (uncomment dex variable name after DataException and add a line here to write a log. ModelState.AddModelError(string.Empty, "Unable to save changes. Try again, and if the problem persists contact your system administrator."); } return(View(customerDTO)); }
public ActionResult Create(string id = "") { LoadCombos(); if (String.IsNullOrWhiteSpace(id) && !String.IsNullOrWhiteSpace(Convert.ToString(Session["ContID"]))) { id = Convert.ToString(Session["ContID"]); } id = string.IsNullOrWhiteSpace(id) ? "0" : Convert.ToString(id); int ContID = int.Parse(id); if (ContID == 0) { ViewBag.Title = BusinessConstants.titleNewCustomer; return(View()); } else { var Contact = CustomerDAL.getEditContact(ContID); Contact.EmailExists = true; ViewBag.Title = BusinessConstants.titleEditCustomer; if (string.IsNullOrWhiteSpace(Contact.SalContEmail)) { Contact.SalContEmail = BusinessConstants.NA; } if (Contact.SalContEmail.Equals(BusinessConstants.NA)) { Contact.SalContEmail = string.Empty; Contact.EmailExists = false; } Session["ContID"] = ContID; return(View(Contact)); } }
static void AddOrder() { var customerDAL = new CustomerDAL(); int store_id = GetStoreID(); if (store_id == -1) { return; } _locManager.PrintInventory(store_id); int oid = _ordManager.Create(current_id, store_id); while (true) { if (GetOrderItem(store_id, oid)) { ; } else { break; } } }
public void Create(Customer newCustomer) { // Call the DAL to create a new record. CustomerDAL customerDAL = new CustomerDAL(); customerDAL.Create(newCustomer); }
public ActionResult Validate(FormCollection formCollection) { Customer login = new Customer(); // Retrieve form data using form collection login.EmailId = formCollection["EmailId"]; login.Password = formCollection["Password"]; List <Customer> loginlist = CustomerDAL.GetAll(); bool status = false; foreach (Customer c in loginlist) { if (c.EmailId.Equals(login.EmailId) && c.Password.Equals(login.Password)) { //return RedirectToAction("Index"); status = true; } } if (status == true) { return(RedirectToAction("Index")); } else { return(View()); } }
public List <Customer> FindAllCustomers() { List <Customer> customerList = new List <Customer>(); customerList = CustomerDAL.FindAllCustomers(); return(customerList); }
public JsonResult display() { CustomerDAL customerObj = new CustomerDAL(); List <Customer> cust = new List <Customer>(); try { var result = customerObj.GetAllCustomers(); foreach (var obj in result) { Customer custobj = new Customer(); custobj.CustomerId = obj.CustomerId; custobj.Name = obj.Name; custobj.DateOfBirth = obj.DateOfBirth; custobj.EmailId = obj.EmailId; custobj.Gender = obj.Gender; custobj.Address = obj.Address; cust.Add(custobj); } return(Json(cust)); } catch (Exception) { return(null); } }
private void btnSave_Click(object sender, RoutedEventArgs e) { if (IsInsert) { Customer customer = (Customer)Grid.DataContext; //customer.Address = textAddress.Text; //customer.BirthDay = textBirthDay.SelectedDate; //customer.CustomerLevel = Convert.ToInt32(textCustomerLevel.Text); //customer.Name = textName.Text; //customer.TelNum = textTelNum.Text; CustomerDAL.Insert(customer); CustomerDAL.GetAll(); } else { Customer customer = (Customer)Grid.DataContext; //customer.Address = textAddress.Text; //customer.BirthDay = textBirthDay.SelectedDate; //customer.CustomerLevel = Convert.ToInt32(textCustomerLevel.Text); //customer.Name = textName.Text; //customer.TelNum = textTelNum.Text; CustomerDAL.Update(customer); //CustomerDAL.GetAll(); } DialogResult = true; }
public static void Main(string[] args) { string connectionString = "Data Source=CHIRAG-DESK\\SQLEXPRESS; Initial Catalog=AutoLot; Integrated Security=true"; InventoryDAL dal = new InventoryDAL(connectionString); CustomerDAL cDal = new CustomerDAL(connectionString); // DisplayInventory(dal); // DisplayCar(dal, -1); // AddCar(dal); // DeleteCar(dal, 44); // DisplayInventory(dal); // UpdateCarPetName(dal); // DisplayInventory(dal); // cDal.ProcessCreditRisk(3, false); // ProcessBulkImport importer = new ProcessBulkImport(connectionString); // if (importer.Execute<Car>(new List<Car>() { // new Car() { Make = "Fiat", Color = "Violet", PetName = "Trio" }, // new Car() { Make = "VW", Color = "Blue", PetName = "Pug" }, // new Car() { Make = "Fort", Color = "Yellow", PetName = "Ben" } // }, "Inventory")) { // Console.WriteLine("Import Successful!"); // } else { // Console.WriteLine("Import Failed!"); // } DisplayInventory(dal); Console.ReadKey(); }
public void InsertTest() { Customer c = new Customer(); c.CustomerID = "222"; ContactInfo ci = new ContactInfo(); ci.Name = "2222"; ci.SpellingCode = "2222222222"; ci.ZipCode = "23124"; ci.Tel = "123123132132"; ci.Fax = "12646546"; ci.Address = "541654564654"; ci.BankName = "瑞士银行"; ci.BankAccount = "88888888888888"; ci.Contacter = "莫"; ci.Email = "*****@*****.**"; c.CustomerContact = ci; CustomerDAL target = new CustomerDAL(); bool atual = target.Insert(c); //实际的结果 bool expected = true; //预期的结果 Assert.AreEqual(expected, atual); //断言判等 //测试无效的 atual = target.Insert(c); //实际的结果 expected = false; //预期的结果 Assert.AreEqual(expected, atual); //断言判等 }
public Customer GetCustomerByID(int customerID) { Customer customer = new Customer(); CustomerDAL customerDAL = new CustomerDAL(); customer = customerDAL.GetCustomerByID(customerID); return customer; }