コード例 #1
0
 public IList <CompletedObjectiveDTO> GetAllCompletedObjectives()
 {
     using (var context = new ObjectiveContext())
     {
         return(_mapper.Map <IList <CompletedObjectiveDTO> >(context.CompletedObjectives.ToList()));
     }
 }
コード例 #2
0
 public IList <CategoryDTO> GetAllCategories()
 {
     using (var context = new ObjectiveContext())
     {
         return(_mapper.Map <IList <CategoryDTO> >(context.Categories.ToList()));
     }
 }
コード例 #3
0
        public void CompleteObjectiveById(int id)
        {
            using (var context = new ObjectiveContext())
            {
                var objective = context.Objectives.FirstOrDefault(obj => obj.Id == id);

                objective.IsCompleted = true;

                context.SaveChanges();

                //SQL Trigger (it works, I checked):

                //CREATE TRIGGER Objective_Complete
                //ON Objectives
                //AFTER UPDATE
                //AS
                //INSERT INTO CompletedObjectives
                //SELECT i.Id, GETDATE()
                //FROM Objectives o
                //INNER JOIN INSERTED i on o.Id = i.id
                //AND i.IsCompleted = 1
            }
        }
コード例 #4
0
 public ObjectiveRepository(ObjectiveContext context)
 {
     this.db = context;
 }
コード例 #5
0
 public ObjectiveRepository(ObjectiveContext context)
 {
     _context = context;
 }
コード例 #6
0
 public EFUnitOfWork(DbContextOptions <ObjectiveContext> options)
 {
     db = new ObjectiveContext(options);
 }
コード例 #7
0
 public ObjectiveController(ObjectiveContext _db)
 {
     db = _db;
 }