示例#1
0
        public void Destroy(ProjectControlViewModel db)
        {
            var entity = new ProjectControl_Table();

            entity.UserID = db.UserID;
            entities.ProjectControl_Table.Attach(entity);
            entities.ProjectControl_Table.Remove(entity);
            entities.SaveChanges();
        }
示例#2
0
        public void Update(ProjectControlViewModel db)
        {
            var entity = new ProjectControl_Table();

            entity.ProjectControlID = db.ProjectControlID;
            entity.UserID           = db.UserID;
            entity.ProjectID        = db.ProjectID;
            entity.Status           = db.Status;



            entities.ProjectControl_Table.Attach(entity);
            entities.Entry(entity).State = EntityState.Modified;
            entities.SaveChanges();
        }
示例#3
0
        public void Create(ProjectControlViewModel db)
        {
            try
            {
                //  تم اضافة هذا الاستعلام لعدم تكرار المشروع للمستخدم
                var project = entities.ProjectControl_Table
                              .Single(i => i.UserID == db.UserID &&
                                      i.ProjectID == db.ProjectID);
                db.ProjectControlID = 0;
            }
            catch (Exception)
            {
                var entity = new ProjectControl_Table();

                entity.UserID    = db.UserID;
                entity.ProjectID = db.ProjectID;
                entity.Status    = db.Status;
                entities.ProjectControl_Table.Add(entity);
                entities.SaveChanges();

                db.ProjectControlID = entity.ProjectControlID;
            }
        }