Пример #1
0
 public HttpResponseMessage CheckLogin([FromBody] AdminModel admin)
 {
     try {
         bool login = adminLogic.CheckAdmin(admin);
         if (!ModelState.IsValid)
         {
             return(Request.CreateResponse(HttpStatusCode.BadRequest, ModelState.GetAllErrors()));
         }
         return(Request.CreateResponse(HttpStatusCode.OK, login));
     }
     catch (Exception ex) {
         return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.GetUsreFriendlyMessage()));
     }
 }
Пример #2
0
 public bool CheckAdmin(AdminModel admin)
 {
     admin.name     = admin.name.Replace(";", " ");
     admin.password = admin.password.Replace(";", " ");
     return(DB.Admins.Any(a => a.Name == admin.name && a.Password == admin.password));
 }