public IHttpActionResult Register(BDF_UserAccount account)
        {
            var result = _context.BDF_UserAccount.Where(e => e.Username == account.Username).FirstOrDefault();

            if (!ModelState.IsValid)
            {
                return(Json(new { ErrorID = 1, ErrorMessage = "Error Occurs" }));
            }
            else
            {
                if (result != null)
                {
                    return(Json(new { ErrorID = 1, ErrorMessage = "this username exists in database" }));
                }

                var user = new BDF_UserAccount();

                user.Username = account.Username;
                user.Password = account.Password;
                user.Email    = account.Email;
                user.RoleID   = 2;


                _context.BDF_UserAccount.Add(user);
            }
            _context.SaveChanges();
            return(Json(new { ErrorID = 2, ErrorMessage = "Created successfully" }));
        }
        public IHttpActionResult LogIn(BDF_UserAccount account)
        {
            bool isAuthorized = _context.BDF_UserAccount.Any(u => u.Username.Equals(account.Username, StringComparison.OrdinalIgnoreCase) && u.Password == account.Password);
            var  user_id      = _context.BDF_UserAccount.Where(e => e.Username == account.Username && e.Password == account.Password).Select(e => e.AccountID).FirstOrDefault();

            var FirstName = _context.BDF_UserProfile.Where(e => e.UserProfileID == user_id).Select(e => e.FirstName).FirstOrDefault();
            var LastName  = _context.BDF_UserProfile.Where(e => e.UserProfileID == user_id).Select(e => e.LastName).FirstOrDefault();
            var role      = _context.BDF_UserAccount.Where(e => e.AccountID == user_id).Select(e => e.BDF_UserRole.RoleName).FirstOrDefault();

            var profile_ID   = _context.BDF_UserProfile.Where(e => e.UserProfileID == user_id).Select(e => e.UserProfileID).FirstOrDefault();
            var profileImage = _context.UserProfile_Images.Where(e => e.ProfileID == profile_ID).Select(e => e.ImageData).FirstOrDefault();



            bool IsProfileCompleted = _context.BDF_UserProfile.Any(e => e.User_Id == user_id);



            var requestsCount = _context.BDF_BloodRequest.Where(e => e.ReceiverAccount_id == user_id && e.Status != "Accepted").ToList().Count;

            if (isAuthorized == false)
            {
                return(Json(new { ErrorID = 1, ErrorMessage = "Invalid username or password" }));
            }
            else
            {
                if (role == "user")
                {
                    return(Json(new { ErrorID = 2, ErrorMessage = "login successfully", RequestsCount = requestsCount, user_id, FirstName, LastName, role, profileImage, IsProfileCompleted }));
                }
                else
                {
                    return(Json(new { ErrorID = 2, ErrorMessage = "login successfully", role }));
                }
            }
        }