Esempio n. 1
0
 public UserDTO Update(string id, UserDTO instance)
 {
     int userID = Int32.Parse(id);
     User u = instance.ToEntity();
     u.PlainText = instance.Password;
     u.UserId = userID;
     return User.Update( userID, u).ToDTO();
 }
Esempio n. 2
0
 public UserDTO validate(UserDTO instance)
 {
     User u =  User.GetUser(instance.Username, instance.Password);
     if (u != null)
     {
         return u.ToDTO();
     }
     else
     {
         return null;
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Invoked when <see cref="ToDTO"/> operation is about to return.
        /// </summary>
        /// <param name="dto"><see cref="UserDTO"/> converted from <see cref="User"/>.</param>
partial         static void OnDTO(this User entity, UserDTO dto);
Esempio n. 4
0
 public UserDTO Create(UserDTO instance)
 {
     User u = instance.ToEntity();
     u.PlainText = instance.Password;
     return User.Add(u).ToDTO();
 }
Esempio n. 5
0
        /// <summary>
        /// Converts this instance of <see cref="User"/> to an instance of <see cref="UserDTO"/>.
        /// </summary>
        /// <param name="entity"><see cref="User"/> to convert.</param>
        public static UserDTO ToDTO(this User entity)
        {
            if (entity == null) return null;

            var dto = new UserDTO();

            dto.UserId = entity.UserId;
            dto.Type = entity.Type;
            dto.Username = entity.Username;
            dto.Password = entity.Password;
            dto.Role = entity.Role;
            dto.IsActive = entity.IsActive;
            dto.Description = entity.Description;
            dto.Email = entity.Email;

            entity.OnDTO(dto);

            return dto;
        }