Beispiel #1
0
 public HttpResponseMessage checkUsers([FromBody] UsersManagements user)
 {
     try
     {
         MessageModel value = new MessageModel();
         value = authenticationUser(user);
         ClassMessages e = new ClassMessages((int)value.idMessage);
         if (value.idMessage == (int)MessageCode.OkUser)
         {
             var qq = context.UsePermition.Where(p => p.UsersManagement.DeviceId == user.DeviceId).FirstOrDefault();
             e.username      = user.username;
             e.password      = user.password;
             e.status        = user.status;
             e.DeviceId      = user.DeviceId;
             e.userpermition = qq.permitionId;
             var message = Request.CreateResponse(HttpStatusCode.OK, e);
             return(message);
         }
         else
         {
             return(Request.CreateResponse(HttpStatusCode.OK, e));
         }
     }
     catch (Exception ex)
     {
         return(Request.CreateResponse(HttpStatusCode.OK, ex));
     }
 }
Beispiel #2
0
 public HttpResponseMessage createUser([FromBody] UsersManagements user)
 {
     try
     {
         MessageModel value = new MessageModel();
         value = authenticationCreateUser(user);
         ClassMessages e = new ClassMessages((int)value.idMessage);
         if (value.idMessage == (int)MessageCode.Savedata)
         {
             UsersManagement u = new UsersManagement
             {
                 username = user.username,
                 password = user.password,
                 status   = user.status,
                 DeviceId = user.DeviceId
             };
             UsePermition up = new UsePermition {
                 permitionId = user.userpermition, UsersManagement = u
             };
             context.UsersManagement.Add(u);
             context.UsePermition.Add(up);
             context.SaveChanges();
             var message = Request.CreateResponse(HttpStatusCode.OK, e);
             return(message);
         }
         else
         {
             return(Request.CreateResponse(HttpStatusCode.OK, e));
         }
     }
     catch (Exception ex)
     {
         ClassMessages e = new ClassMessages(5);
         return(Request.CreateResponse(HttpStatusCode.OK, e));
     }
 }