コード例 #1
0
        public ApiSimpleResult<UserModel> SaveUser(UserModel user)
        {
            var result = new ApiSimpleResult<UserModel>();
            var response = AccountSvc.SaveUser(user);
            if (response != null)
            {
                result.Data = response;
            }

            return result;
        }
コード例 #2
0
 public UserModel GetUserDetails(int userId)
 {
     UserModel result = new UserModel();
     var users = db.Users.Where(r => r.UserId == userId);
     if (users.Any())
     {
         var user = users.First();
         result.Id = user.UserId;
         result.UserName = user.UserName;
         result.Email = user.Email;
         result.Status = user.Status;
     }
     return result;
 }
コード例 #3
0
 public UserModel CreateUser(UserQueryModel userQuery)
 {
     var status = new GeneralStatus
     {
         StatusName = userQuery.Status,
         CreateTime = DateTime.Now,
         UpdateTime = DateTime.Now
     };
     db.GeneralStatuses.Add(status);
     UserModel result = new UserModel();
     var user = new User { UserName = userQuery.UserName, Email = userQuery.Email, StatusId = status.StatusId };
     db.Users.Add(user);
     db.SaveChanges();
     result = new UserModel
     {
         Id = user.UserId,
         UserName = user.UserName,
         Email = user.Email,
         Status = user.Status
     };
     return result;
 }
コード例 #4
0
 public UserModel SaveUser(UserModel user)
 {
     var result = new UserModel();
     var status = db.GeneralStatuses.Find(user.Status.StatusId);
     status.UpdateTime = DateTime.Now;
     status.StatusName = user.Status.StatusName;
     db.Entry(status).State = EntityState.Modified;
     var updateUser = db.Users.Find(user.Id);
     updateUser.UserName = user.UserName;
     updateUser.Email = user.Email;
     updateUser.Status = user.Status;
     db.Entry(updateUser).State = EntityState.Modified;
     try
     {
         db.SaveChanges();
         result.Id = user.Id;
     }
     catch (DbUpdateConcurrencyException ex)
     {
         return null;
     }
     return result;
 }
コード例 #5
0
 public ApiSimpleResult<UserModel> DeleteUser(UserModel user)
 {
     var response = AccountSvc.DeleteUser(user);
     return response;
 }
コード例 #6
0
 public ApiSimpleResult<UserModel> DeleteUser(UserModel user)
 {
     var status = db.GeneralStatuses.Find(user.Status.StatusId);
     db.Entry(status).State = EntityState.Deleted;
     var deleteUser = db.Users.Find(user.Id);
     db.Entry(deleteUser).State = EntityState.Deleted;
     var result = new ApiSimpleResult<UserModel>();
     try
     {
         db.SaveChanges();
         result.StatusString = "Successful";
         result.Message = "Delete data successfully";
         result.Data = user;
     }
     catch (DbUpdateConcurrencyException ex)
     {
         result.Message = "Error";
         result.StatusString = "Error";
     }
     return result;
 }
コード例 #7
0
 public UserModel GetUserById(int id)
 {
     UserModel results = new UserModel();
     var query = from u in DbContext.Users where u.UserId == id
                 select new UserModel { Id = u.UserId, UserName = u.UserName, Email = u.Email, Status = u.Status };
     if (query.Any())
     {
         results = query.First();
     }
     return results;
 }