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(); }
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(); }
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; } }