//login public Account isAuthenticated(string username, string passwd) { var list = Repositoty.GetAccountByUsenameAsync(username).Result.ToList(); //test if (username == "*****@*****.**") { if (list.Exists(p => p.passwd == passwd)) { return(list.FirstOrDefault()); } } string encryptedpass = ExtensionTools.GetMD5(passwd); foreach (var item in list) { if (item.passwd.Equals(encryptedpass)) { return(item); } } return(null); }
public async Task <bool> SignUpAsync(RegisterMerchantModelView model) { string idMer, idAcc; var tran = this.ShoeEcommerceDBContext.Database.BeginTransaction(); try { //merchant idMer = await this.GetNextIdAsync(); this.Create(new Merchant() { idMerchant = idMer, fstname = model.fstname, lstname = model.lstname, storename = model.storename, phone = model.phone, website = model.website, stt = false }); await this.SaveAsync(); //account Merchant var accRepos = new AccountRepository(this.ShoeEcommerceDBContext); idAcc = await accRepos.GetNextId(); accRepos.Create(new Account() { idAccount = idAcc, username = model.username, passwd = ExtensionTools.GetMD5(model.password), avt_path = ExtensionTools.GetFullMerchantPath(model.avt_path), rate = 1, rankVip = "default", CreatedDate = DateTime.Now, idCustomer = "noone", IdMerchant = idMer, //chờ admin kiểm duyệt stt = false }); await accRepos.SaveAsync(); //email var emailRepos = new EmailRepository(this.ShoeEcommerceDBContext); emailRepos.Create(new Email() { id = await emailRepos.GetNextIdAsync(), email = model.email, IdAccount = idAcc, stt = true }); await emailRepos.SaveAsync(); //address var addressRepos = new AddressRepository(this.ShoeEcommerceDBContext); addressRepos.Create(new Address() { id = await addressRepos.GetNextId(), add_Info = model.add_Info, City_Provine = model.City_Provine, District_town = model.District_town, subDistrict = model.subDistrict, idAccount = idAcc, stt = true }); await addressRepos.SaveAsync(); //Thêm thông báo cho addmin var Add_on = new RegisterNotifyRepsitory(this.ShoeEcommerceDBContext); Add_on.Create(new RegisterNotify() { id = await Add_on.GetNextIdAsync(), id_Acc = idAcc, id_Mer = idMer, Checked = false, createdDate = DateTime.Now, stt = true }); await Add_on.SaveAsync(); tran.Commit(); tran.Dispose(); return(true); } catch (Exception ex) { tran.Rollback(); tran.Dispose(); return(false); } }
public async Task <bool> RegisterAsync(RegisterModelView modelView) { string idcus; string idAcc; var tran = this.ShoeEcommerceDBContext.Database.BeginTransaction(); try { //customer var cusRepo = new CustomerRepository(this.ShoeEcommerceDBContext); idcus = await cusRepo.GetNextId(); var cus = new Customer() { idCustomer = idcus, fstname = modelView.fstname, lstname = modelView.lstname, phone = modelView.phone, stt = true }; cusRepo.Create(cus); await cusRepo.SaveAsync(); //account idAcc = await GetNextId(); var acc = new Account() { idAccount = idAcc, username = modelView.username, passwd = ExtensionTools.GetMD5(modelView.password), avt_path = ExtensionTools.GetFullPath(modelView.avt_path), rankVip = "default", rate = 1, IdMerchant = "noone", idCustomer = idcus, CreatedDate = DateTime.Now, stt = true }; Create(acc); await SaveAsync(); //email var EmailRepo = new EmailRepository(this.ShoeEcommerceDBContext); EmailRepo.Create(new Email() { id = await EmailRepo.GetNextIdAsync(), email = modelView.email, IdAccount = idAcc, stt = true }); await EmailRepo.SaveAsync(); //Address var AddressRepos = new AddressRepository(this.ShoeEcommerceDBContext); AddressRepos.Create(new Address() { id = await AddressRepos.GetNextId(), add_Info = modelView.add_Info, City_Provine = modelView.City_Provine, District_town = modelView.District_town, subDistrict = modelView.subDistrict, idAccount = idAcc, stt = true }); await AddressRepos.SaveAsync(); tran.Commit(); tran.Dispose(); return(true); } catch (Exception ex) { tran.Rollback(); tran.Dispose(); return(false); } }