/// <summary>
        /// Converts this instance of <see cref="UserDTO"/> to an instance of <see cref="User"/>.
        /// </summary>
        /// <param name="dto"><see cref="UserDTO"/> to convert.</param>
        public static User ToEntity(this UserDTO dto)
        {
            if (dto == null) return null;

            var entity = new User();

            entity.UserID = dto.UserID;
            entity.UserName = dto.UserName;
            entity.FirstName = dto.FirstName;
            entity.MiddleName = dto.MiddleName;
            entity.LastName = dto.LastName;
            entity.DOB = dto.DOB;
            entity.IsActive = dto.IsActive;
            entity.IsDeleted = dto.IsDeleted;
            entity.insuser = dto.insuser;
            entity.insdt = dto.insdt;
            entity.upduser = dto.upduser;
            entity.upddt = dto.upddt;

            dto.OnEntity(entity);

            return entity;
        }
Beispiel #2
0
        public User CreateUser(User oUser) {
            User oUserReturn = null;

            using (DBContext)
            {
                try {
                    oUserReturn = DBContext.Users.Add(oUser);
                    DBContext.SaveChanges();
                }
                catch (Exception ex) {
                    //Log Exception.
                }
            }

            return oUserReturn;
        }
Beispiel #3
0
        public User UpdateUser(User oUser)
        {
            User oUserReturn = null;
            if (oUser != null && oUser.UserID > 0)
            {
                using (DBContext)
                {
                    User u = this.GetUserByID(oUser.UserID);

                    if (u != null)
                    {
                        Mapper.Map<User, User>(oUser, u);
                        DBContext.SaveChanges();
                        oUserReturn = u;
                    }
                }
            }

            return oUserReturn;
        }
Beispiel #4
0
 /// <summary>
 /// Invoked when <see cref="ToEntity"/> operation is about to return.
 /// </summary>
 /// <param name="entity"><see cref="User"/> converted from <see cref="UserDTO"/>.</param>
 static partial void OnEntity(this UserDTO dto, User entity) { 
 
 }