예제 #1
0
 public async Task <IActionResult> SignUp([Bind("username,password,avt_path,lstname,fstname,storename,phone,website,add_Info,subDistrict,District_town,City_Provine,email")] RegisterMerchantModelView model)
 {
     if (await merService.SignUpAsync(model))
     {
         TempData["mes"] = $"Đăng kí tài khoản {model.username} thàng công chờ kiểm duyệt";
     }
     else
     {
         TempData["mes"] = "Đăng kí thất bại, yêu cầu sử dụng thông tin chính xác";
     }
     return(View(model));
 }
예제 #2
0
 public async Task <bool> SignUpAsync(RegisterMerchantModelView model)
 {
     return(await Repository.SignUpAsync(model));
 }
예제 #3
0
        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);
            }
        }