/// <summary>
 /// Maps a model to an entity.
 /// </summary>
 /// <param name="model">The model.</param>
 /// <returns></returns>
 public static Duende.IdentityServer.EntityFramework.Entities.Client ToEntity(this Models.Client model)
 {
     return(Mapper.Map <Duende.IdentityServer.EntityFramework.Entities.Client>(model));
 }
 public ActionResult SetKeyword(Client client)
 {
     BankUser user = (BankUser)Session["user"];
     if (user == null)
     {
         FormsAuthentication.SignOut();
         return View(new Login());
     }
     if (client == null || string.IsNullOrEmpty(client.Keyword) || !Regex.IsMatch(client.Keyword, "^[0-9a-zA-Z]{1,10}$"))
     {
         ModelState.AddModelError("Keyword", "Keyword should not be empty.");
         return View("SetKeyword", user.Client);
     }
     try
     {
         user.Client.Keyword = client.Keyword;
         ClientDAL.Instance.UpdateClientKeyword(user.Client);
         return View("KeywordSuccess");
     }
     catch (Exception)
     {
         return RedirectToInternalError();
     }
 }
        public async Task<IHttpActionResult> Register(RegisterBindingModel model)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            User user;

            if (model.IsEmployee)
            {
                user = new Employee { Email = model.Email, UserName = model.Email, FirstName = model.FirstName, LastName = model.LastName, UType = UType.Employee };
            }
            else
            {
                user = new Client { Email = model.Email, UserName = model.Email, FirstName = model.FirstName, LastName = model.LastName, UType = UType.Client };
            }

            IdentityResult result = await UserManager.CreateAsync(user, model.Password);

            if (!result.Succeeded)
            {
                return GetErrorResult(result);
            }

            return Ok();
        }