public void Add(string accType, string name, string lastname)
        {
            using (AcountStorageDB db = new AcountStorageDB())
            {
                Account acc = new BaseAccount(name, lastname);
                switch (accType)
                {
                case "Basic":
                    acc = new BaseAccount(name, lastname);
                    break;

                case "Gold":
                    acc = new GoldAccount(name, lastname);
                    break;

                case "Platinum":
                    acc = new PlatinumAccount(name, lastname);
                    break;
                }
                AcountModel acount = new AcountModel();
                acount.accid         = acc.AccId;
                acount.ownerName     = acc.OwnerName;
                acount.ownerLastname = acc.OwnerLastName;
                acount.balance       = acc.Balance;
                acount.bonusPoints   = acc.BonusPoints;
                acount.acouintType   = accType;
            }
        }
Example #2
0
        public async Task <IActionResult> Login([FromBody] Dictionary <string, string> param)
        {
            var userName = param["username"]?.ToString();
            var password = param["password"]?.ToString();

            var userInfo = await _accountService.Login(userName, password);

            if (userInfo != null)
            {
                var postion = new AcountModel();
                if (userName == "namht1")
                {
                    postion.Id     = "208";
                    postion.UserId = "SCB Nguyễn Sơn";
                    postion.Pass   = "";
                }

                if (postion.UserId == null)
                {
                    return(NotFound(new { code = "404", message = $"Người dùng không tồn tại mã chi nhánh." }));
                }
                if (postion.Pass == null)
                {
                    return(NotFound(new { code = "404", message = $"Người dùng chưa đăng ký phòng ban." }));
                }
                //var menus = await _roleService.GetMenusAsync(roles);

                var accToken = await this.GenerateLocalAccessTokenResponse(new Dictionary <string, object>()
                {
                    { ClaimTypes.Sid, postion.Id },
                    { ClaimTypes.NameIdentifier, postion.UserId },
                    { ClaimTypes.Name, postion.Pass },
                });

                var data = new
                {
                    token = accToken,
                    info  = new
                    {
                        id       = postion.Id,
                        username = postion.UserId,
                        fullname = postion.Pass
                    },
                    //menus
                };
                return(Ok(new { code = "LOGIN_OK", data, message = "Success" }));
            }

            return(NotFound(new { code = "LOGIN_NOT_FOUND", message = "Tên người dùng hoặc mật khẩu không chính xác." }));
        }
        public void Remove(string id)
        {
            using (AcountStorageDB db = new AcountStorageDB())
            {
                AcountModel acc = db.Acounts.SingleOrDefault(t => t.accid == id);

                if (acc != null)
                {
                    db.Acounts.Remove(acc);
                    db.SaveChanges();
                }
                else
                {
                    throw new ArgumentException("There are no Account with such id:" + id);
                }
            }
        }
        public Account GetByID(string id)
        {
            using (AcountStorageDB db = new AcountStorageDB())
            {
                AcountModel acc = db.Acounts.SingleOrDefault(t => t.accid == id);
                if (acc != null)
                {
                    Account accentity;
                    switch (acc.acouintType)
                    {
                    case "Basic":
                        accentity = new BaseAccount(acc.ownerName, acc.ownerLastname, acc.accid);
                        break;

                    case "Gold":
                        accentity = new GoldAccount(acc.ownerName, acc.ownerLastname, acc.accid);
                        break;

                    case "Platinum":
                        accentity = new PlatinumAccount(acc.ownerName, acc.ownerLastname, acc.accid);
                        break;

                    default:
                        accentity = new BaseAccount(acc.ownerName, acc.ownerLastname, acc.accid);
                        break;
                    }

                    accentity.BonusPoints = acc.bonusPoints;
                    accentity.Balance     = acc.balance;

                    return(accentity);
                }
                else
                {
                    throw new ArgumentException("There are no Account with such id:" + id);
                }
            }
        }
Example #5
0
        public bool Create(AcountModel model)
        {
            string msgError = "";

            try
            {
                var result = _dbHelper.ExecuteScalarSProcedureWithTransaction(out msgError, "ac_item_create",
                                                                              "@acountid", model.acountid,
                                                                              "@username", model.username,
                                                                              "@passwordd", model.passwordd,
                                                                              "@acountstate", model.acountstate,
                                                                              "@isadminacount", model.isadminacount);
                if ((result != null && !string.IsNullOrEmpty(result.ToString())) || !string.IsNullOrEmpty(msgError))
                {
                    throw new Exception(Convert.ToString(result) + msgError);
                }
                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #6
0
 public AcountModel UpdateAcount([FromBody] AcountModel model)
 {
     _itemBusiness.Update(model);
     return(model);
 }
Example #7
0
 public AcountModel CreateItem([FromBody] AcountModel model)
 {
     _itemBusiness.Create(model);
     return(model);
 }
Example #8
0
 public bool Create(AcountModel model)
 {
     return(_res.Create(model));
 }
Example #9
0
 public bool Update(AcountModel model)
 {
     return(_res.Update(model));
 }
Example #10
0
 public ActionResult LoginAjax(AcountModel model)
 {
     return(View());
 }