Example #1
0
        public async Task <IHttpActionResult> Register(Account_BenhNhanDTO account)
        {
            var acc = await db.Account_BenhNhan.FirstOrDefaultAsync(q => q.Username == account.MaYTe && q.Status == "ACTIVE");

            if (acc == null)
            {
                var bn = db.SP_DM_BenhNhan_GetByMaYTe(account.MaYTe).FirstOrDefault();
                if (bn != null)
                {
                    if (bn.TenBenhNhan.ToUpper().Equals(account.HoTen.ToUpper()) && bn.NgaySinh?.OnlyDate() == account.NgaySinh.OnlyDate())
                    {
                        var id = db.SP_Account_BenhNhan_Insert(account.Password, account.Email, account.MaYTe).FirstOrDefault();
                        if (id != null)
                        {
                            if (_sendMailConfirm(id.IDAccountBN ?? 0))
                            {
                                return(Ok("Vui lòng xác nhận tài khoản, kiểm tra mail " + account.Email));
                            }
                            return(Content(HttpStatusCode.Created, "Vui lòng xác nhận tài khoản, thử lại gửi mail: " + account.Email));
                        }
                        else
                        {
                            return(BadRequest());
                        }
                    }
                    else
                    {
                        return(Content(HttpStatusCode.NotAcceptable, "Thông tin họ tên và ngày sinh không trùng khớp với Mã Y Tế."));
                    }
                }
                else
                {
                    return(Content(HttpStatusCode.NotAcceptable, "Mã y tế không tồn tại."));
                }
            }
            else
            {
                if (acc.Status == CONFIRM)
                {
                    return(Content(HttpStatusCode.Created, "Vui lòng xác nhận tài khoản với email " + acc.Email));
                }
                else if (acc.Status == ACTIVE)
                {
                    return(Content(HttpStatusCode.NotAcceptable, "Thông tin Mã Y tế đã được sử dụng."));
                }
                return(Content(HttpStatusCode.NotAcceptable, "Tài khoản đã được tạo trước đó."));
            }
        }
Example #2
0
        public async Task <KeyValuePair <int, string> > Register(Account_BenhNhanDTO account)
        {
            var res = await API.POSTAsynsCode <string>($"apis/{controlerAPI}/Register", account);

            int code = 0; // FAIL

            if (res.Key == HttpStatusCode.OK)
            {
                code = 1; // CONFIRM
            }
            else if (res.Key == HttpStatusCode.Created)
            {
                code = 2; // Created => CONFIRM
            }
            else if (res.Key == HttpStatusCode.NotAcceptable)
            {
                code = 3; // ACTIVE
            }
            return(new KeyValuePair <int, string>(code, res.Value));
        }
        public async Task <ActionResult> Register(Account_BenhNhanDTO account)
        {
            var res = await new AuthenticateBUS().Register(account);

            switch (res.Key)
            {
            case 0:
                ModelState.AddModelError("", "Đăng kí thất bại");
                break;

            case 1:
            case 2:
                return(RedirectToAction("Confirm", account));

            case 3:
                ModelState.AddModelError("", res.Value);
                break;

            default:
                break;
            }
            return(View());
        }
 public ActionResult Confirm(Account_BenhNhanDTO account)
 {
     return(View(account));
 }
Example #5
0
 public bool Update(Account_BenhNhanDTO account)
 {
     return(API.PUT <string>($"api/{controlerAPI}/{account.IDAccountBN}", account).Key);
 }
Example #6
0
 public bool Create(Account_BenhNhanDTO account)
 {
     return(API.POST <object>($"api/{controlerAPI}", account).Key);
 }