Esempio n. 1
0
        /// <summary>
        /// The create user.
        /// </summary>
        /// <param name="user">
        /// The user.
        /// </param>
        /// <returns>
        /// The <see cref="int"/>.
        /// </returns>
        public int CreateUser(NewUser user)
        {
            var createcontext =
                new ScrumNotesDbClassDataContext(
                    ConfigurationManager.ConnectionStrings["ScrumNotesCombinerConnectionString"].ToString());
            int users = (from u in createcontext.Users where u.ADUserName.Equals(user.ADname) select u).Count();
            try
            {
                if (users != 0)
                {
                    return 2;
                }

                int newid = createcontext.Users.Count() + 1;
                var record = new User
                                 {
                                     Id = newid,
                                     ADUserName = user.ADname,
                                     Allias = user.Name,
                                     Email = user.Email,
                                     Comments = user.Comments
                                 };
                createcontext.Users.InsertOnSubmit(record);
                createcontext.Users.Context.SubmitChanges();
                createcontext.Dispose();
                return 0;
            }
            catch (Exception e)
            {
                return 1;
            }
        }
 partial void UpdateUser(User instance);
 partial void DeleteUser(User instance);
 partial void InsertUser(User instance);