Пример #1
0
 public BTDetail GetBTById(int id)
 {
     using (var ctx = new ApplicationDbContext())
     {
         BulkTechSamples entity = ctx.BulkTechSamples.SingleOrDefault(e => e.BTId == id);
         if (entity.Employee != null)
         {
             return(new BTDetail
             {
                 BTId = entity.BTId,
                 IsComplete = entity.IsComplete,
                 DueOnDate = entity.DueOnDate,
                 CompletedOnDate = entity.CompletedOnDate,
                 Employee = entity.Employee.FirstName + " " + entity.Employee.LastName
             });
         }
         else
         {
             return(new BTDetail
             {
                 BTId = entity.BTId,
                 IsComplete = entity.IsComplete,
                 DueOnDate = entity.DueOnDate,
                 CompletedOnDate = entity.CompletedOnDate
             });
         }
     }
 }
Пример #2
0
        //END OF TEST

        public bool DeleteBT(int id)
        {
            using (var ctx = new ApplicationDbContext())
            {
                BulkTechSamples entity = ctx.BulkTechSamples.SingleOrDefault(e => e.BTId == id);

                ctx.BulkTechSamples.Remove(entity);

                return(ctx.SaveChanges() == 1);
            }
        }
Пример #3
0
        //TEST
        public bool UpdateBTCompletedBy(BTEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                BulkTechSamples entity = ctx.BulkTechSamples.SingleOrDefault(e => e.BTId == model.BTId);
                //entity.DueOnDate = model.DueOnDate;
                entity.CompletedOnDate = DateTime.Now;
                entity.IsComplete      = true;
                entity.EmployeeId      = model.EmployeeId;

                return(ctx.SaveChanges() == 1);
            }
        }
Пример #4
0
        public bool BTCreate(BTCreate model)
        {
            BulkTechSamples entity = new BulkTechSamples()
            {
                DueOnDate  = model.DueOnDate,
                IsComplete = false
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.BulkTechSamples.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }