public ActionResult <User> Register([FromBody] RegisterPayload registerPayload)
        {
            try
            {
                MailAddress m = new MailAddress(registerPayload.Email);
            }
            catch (Exception)
            {
                return(new JsonResult(new { status = "false", message = "email format " + registerPayload.Email }));
            }


            try
            {
                var existingUserWithMail = _db.Users
                                           .Any(u => u.Email == registerPayload.Email);

                if (existingUserWithMail)
                {
                    return(new JsonResult(new { status = "false", message = "An account with this email already exists " }));
                }
                string link;
                if (registerPayload.gender == "female")
                {
                    link = "female.jpg";
                }
                else
                {
                    link = "man.jpg";
                }
                var userToCreate = new User
                {
                    Email      = registerPayload.Email,
                    ProfilePic = new ImgURL {
                        ImgUrl = link
                    },
                    FirstName    = registerPayload.FirstName,
                    LastName     = registerPayload.LastName,
                    FullName     = registerPayload.FirstName + " " + registerPayload.LastName,
                    PasswordHash = BCrypt.Net.BCrypt.HashPassword(registerPayload.Password),
                    Role         = "SimpleUser",
                };

                _db.Users.Add(userToCreate);



                _db.SaveChanges();

                return(Ok(new { status = true, user = userToCreate }));
            }
            catch (Exception ex)
            {
                return(new JsonResult(new { status = "false", message = "" + ex.Message }));
            }
        }
        public ActionResult <User> Register([FromBody] RegisterPayload registerPayload)
        {
            try
            {
                MailAddress m = new MailAddress(registerPayload.Email);
            }
            catch (Exception ex)
            {
                return(new JsonResult(new { status = "false", message = "email format " + registerPayload.Email }));
            }


            try
            {
                var existingUserWithMail = _db.Users
                                           .Any(u => u.Email == registerPayload.Email);
                var existingUserWithUserName = _db.Users
                                               .Any(u => u.UserName == registerPayload.UserName);

                if (existingUserWithMail)
                {
                    return(Conflict(new { status = false, message = "Email Exists" }));
                }
                if (existingUserWithUserName)
                {
                    return(Conflict(new { status = false, message = "UserName already exists." }));
                }

                var userToCreate = new User
                {
                    Email        = registerPayload.Email,
                    UserName     = registerPayload.UserName,
                    PasswordHash = BCrypt.Net.BCrypt.HashPassword(registerPayload.Password),
                    Gender       = registerPayload.Gender,
                    Role         = "SimpleUser",
                };

                _db.Users.Add(userToCreate);



                _db.SaveChanges();

                return(Ok(new { status = true, user = userToCreate, firstname = registerPayload.UserName }));
            }
            catch (Exception ex)
            {
                return(new JsonResult(new { status = "false", message = "" + ex.Message }));
            }
        }