コード例 #1
0
    public UserDetail GetUserInfo() {
      var id = (CustomIdentity)User.Identity;

      var p = DBContext.Person.Find(id.PersonID);
      var newperson = new UserDetail {
        FirstName = p.FirstName,
        LastName = p.LastName,
        MiddleName = p.MiddleName,
        PersonID = p.PersonID,
        Prefix = p.Prefix,
        UserName = p.UserName, 
        RoleID = id.RoleID,
        Password = string.Empty
      };
      UpdateSession();

      return newperson;
    }
コード例 #2
0
 public HttpResponseMessage AddStudent(UserDetail student) {
   if (this.ModelState.IsValid) {
     try {
       // roleid = 1 ---> student
       DBContext.usp_AddNewUser(student.UserName, student.Prefix, student.LastName, student.MiddleName, student.FirstName, student.Password, 1);
       var response = Request.CreateResponse(HttpStatusCode.Created);
       return response;
     }
     catch (EntityCommandExecutionException ece_exc) {
       if (ece_exc.InnerException.GetType() == typeof(SqlException)) {
         SqlException sqlexc = (SqlException)ece_exc.InnerException;
         if (sqlexc.Number == 50000) throw new SPException(sqlexc.Message);
         else throw new DBException(sqlexc.Message);
       }
       else {
         throw ece_exc.InnerException;
       }
     }
   }
   else {
     return Request.CreateResponse(HttpStatusCode.BadRequest, this.ModelState);
   }
 }