Exemplo n.º 1
0
 public static void CreateOwner(user_owner no)
 {
     using (DALContext cnx = new DALContext())
     {
         cnx.user_owner.AddObject(no);
         cnx.SaveChanges();
     }
 }
 /// <summary>
 /// Создание нового объекта user_owner.
 /// </summary>
 /// <param name="id">Исходное значение свойства id.</param>
 /// <param name="user_id">Исходное значение свойства user_id.</param>
 /// <param name="franchaser_id">Исходное значение свойства franchaser_id.</param>
 /// <param name="first_name">Исходное значение свойства first_name.</param>
 /// <param name="last_name">Исходное значение свойства last_name.</param>
 /// <param name="telephone">Исходное значение свойства telephone.</param>
 /// <param name="email">Исходное значение свойства email.</param>
 public static user_owner Createuser_owner(global::System.Int32 id, global::System.String user_id, global::System.Int32 franchaser_id, global::System.String first_name, global::System.String last_name, global::System.String telephone, global::System.String email)
 {
     user_owner user_owner = new user_owner();
     user_owner.id = id;
     user_owner.user_id = user_id;
     user_owner.franchaser_id = franchaser_id;
     user_owner.first_name = first_name;
     user_owner.last_name = last_name;
     user_owner.telephone = telephone;
     user_owner.email = email;
     return user_owner;
 }
 /// <summary>
 /// Устаревший метод для добавления новых объектов в набор EntitySet user_owner. Взамен можно использовать метод .Add связанного свойства ObjectSet&lt;T&gt;.
 /// </summary>
 public void AddTouser_owner(user_owner user_owner)
 {
     base.AddObject("user_owner", user_owner);
 }
        public ActionResult CreateOwner(NewOwner no)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    MembershipUser mu = Membership.CreateUser(no.Email, no.Password, no.Email);

                    if (mu != null)
                    {
                        System.Web.Security.Roles.AddUserToRole(no.Email, "owner");
                        user_owner newOwner = new user_owner
                        {
                            first_name = no.FirstName,
                            last_name = no.LastName,
                            email = no.Email,
                            telephone = no.Phone,
                            franchaser_id = no.FranchizerId,
                            user_id = (string)mu.ProviderUserKey
                        };
                        DataManager.CreateOwner(newOwner);
                    }
                }
                catch (MembershipCreateUserException muex)
                {
                    TempData["Error"] = Helper.GetMembershipUserCreateStatus(muex.StatusCode);
                }
                catch (Exception ex)
                {
                    TempData["Error"] = ex.Message;
                }
            }

            return RedirectToAction("CreateOwner");
        }