public ActionResult Register(client client)
 {
     JsonResult result;
     try
     {
         string error = AuthProvider.Register(client);
         result = new JsonResult
         {
             JsonRequestBehavior = JsonRequestBehavior.AllowGet,
             Data = new
             {
                 success = error.Length == 0,
                 errorReason = error
             }
         };
     }
     catch (Exception)
     {
         result = new JsonResult
         {
             JsonRequestBehavior = JsonRequestBehavior.AllowGet,
             Data = new
             {
                 success = false,
                 errorReason = "unknown"
             }
         };
     }
     return result;
 }
 public static string Register(client client)
 {
     string result;
     using (var db = new DatabaseModel())
     {
         if (db.client.Any(c => c.Email.ToLower() == client.Email.ToLower()))
         {
             result = "userExists";
         }
         else
         {
             db.client.Add(client);
             db.SaveChanges();
             result = "";
         }
     }
     return result;
 }