Ejemplo n.º 1
0
        public RedirectToRouteResult Create([Bind(Exclude = "Id")]App newApp)
        {
            if (ModelState.IsValid)
            {
                application app = new application();
                app.app_name = newApp.Name;
                app.is_active = newApp.IsActive;
                app.owner_id = Convert.ToInt32(Session["OwnerId"]);
                TempData["Test"] = DataManager.CreateApp(app);
            }

            return RedirectToAction("List");
        }
Ejemplo n.º 2
0
        public static int CreateApp(application app)
        {
            int modificationCount = 0;

            using (DALContext cnx = new DALContext())
            {
                cnx.application.AddObject(app);
                modificationCount += cnx.SaveChanges();

                cnx.skins.AddObject(new skins
                {
                    app_id = app.id
                });
                cnx.themes.AddObject(new themes
                {
                    app_id = app.id
                });
                modificationCount += cnx.SaveChanges();
            }

            return modificationCount;
        }
Ejemplo n.º 3
0
 public static int UpdateApp(application app)
 {
     using (DALContext cnx = new DALContext())
     {
         application realApp = cnx.application.Where(x => x.id == app.id && x.owner_id == app.owner_id).FirstOrDefault();
         if (realApp != null)
         {
             realApp.is_active = app.is_active;
             realApp.app_name = app.app_name;
             return cnx.SaveChanges();
         }
         else return 0;
     }
 }
 /// <summary>
 /// Устаревший метод для добавления новых объектов в набор EntitySet application. Взамен можно использовать метод .Add связанного свойства ObjectSet&lt;T&gt;.
 /// </summary>
 public void AddToapplication(application application)
 {
     base.AddObject("application", application);
 }
 /// <summary>
 /// Создание нового объекта application.
 /// </summary>
 /// <param name="id">Исходное значение свойства id.</param>
 /// <param name="is_active">Исходное значение свойства is_active.</param>
 /// <param name="owner_id">Исходное значение свойства owner_id.</param>
 /// <param name="server_timestamp">Исходное значение свойства server_timestamp.</param>
 public static application Createapplication(global::System.Int32 id, global::System.Boolean is_active, global::System.Int32 owner_id, global::System.DateTime server_timestamp)
 {
     application application = new application();
     application.id = id;
     application.is_active = is_active;
     application.owner_id = owner_id;
     application.server_timestamp = server_timestamp;
     return application;
 }
Ejemplo n.º 6
0
        public RedirectToRouteResult Update(App app)
        {
            if (ModelState.IsValid)
            {
                application updatedApp = new application
                {
                    id = app.Id,
                    app_name = app.Name,
                    is_active = app.IsActive,
                    owner_id = Convert.ToInt32(Session["OwnerId"])
                };
                DataManager.UpdateApp(updatedApp);
            }

            return RedirectToAction("List");
        }