Пример #1
0
        // GET: Updates/GetPublicUpdates

        //POST: Updates/AddUpdatePublicUpdate

        
        // GET: Updates/Create
        public ActionResult Create()
        {
            int userId = DAL.GetUserId(User.Identity.Name);
            UserInfoModel info = DAL.GetUserInfo(userId);
            var now = (DateTime)DateTime.Now;
            ViewData["userinfo"] = info;
            var update = new Update
            {
                UpdateDate = now
                //UpdateTypeId = 1
            };
            return View(update);
        }
Пример #2
0
 private static bool ExecuteDB(Update updates, DBQueryType queryType)
 {
     using (spiffaiwebEntities db = LoadDB())
     {
         switch (queryType)
         {
             case DBQueryType.Add:
                 db.Updates.Add(updates);
                 break;
             case DBQueryType.Update:
                 db.Updates.Attach(updates);
                 db.Entry(updates).State = System.Data.Entity.EntityState.Modified;
                 break;
             case DBQueryType.Delete:
                 db.Updates.Remove(updates);
                 break;
             default:
                 break;
         }
         db.SaveChanges();
     }
     return true;
 }
Пример #3
0
 public static bool Delete(Update updates)
 {
     return ExecuteDB(updates, DBQueryType.Delete);
 }
Пример #4
0
 public static bool Add(Update updates)
 {
     return ExecuteDB(updates, DBQueryType.Add);
 }
Пример #5
0
	    public static string AddEditUpdate(Update update)
	    {
            spiffaiwebEntities db = new spiffaiwebEntities();
	        string response = "";
	        try
	        {
                if (update.UpdateId > 0)
                {
                    //Edit
                    db.Entry(update).State = EntityState.Modified;
                    db.SaveChanges();
                    response = "Succcess";
                }
                else
                {
                    //Create
                    db.Updates.Add(update);
                    db.SaveChanges();
                    response = "Success";
                }
            }
	        catch (Exception)
	        {
	            response = "Error";
	            throw;
	        }
	        return response;
	    }