Exemplo n.º 1
0
        public ActionResult AddEditlab(int?id, lab model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    bool isNew = !id.HasValue;

                    if (isNew)
                    {
                        _repo.labs.Insert(model);
                        _repo.Save();
                    }
                    else
                    {
                        _repo.labs.Update(model);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(RedirectToAction("Index"));
        }
Exemplo n.º 2
0
        private void AddStudToLab(student s, lab l)
        {
            // add stud to new lab
            context.AddStudToLab(s, l);

            // add present for each labdate for student
            context.GetLabdatesOfLab(l.labID)
            .ForEach(lD => {
                dataAccess.PresentContext.AddOne(
                    new present {
                    labdate_labdateID = lD.labdateID,
                    note = "",
                    student_studentID = s.studentID,
                    wasPresent        = 0
                });
            });

            // add TaskDone for each Task for student
            context.GetTasksOfLab(l.labID)
            .ForEach(t => {
                dataAccess.TaskDoneContext.AddOne(
                    new taskdone {
                    isDone            = 0,
                    student_studentID = s.studentID,
                    task_taskID       = t.taskID
                });
            });
        }
        public ActionResult Save(lab com)
        {
            bool status = false;

            if (ModelState.IsValid)
            {
                using (TCMSDBEntities dc = new TCMSDBEntities())
                {
                    if (com.LabNo > 0)
                    {
                        // Edit
                        var v = dc.labs.Where(a => a.LabNo == com.LabNo).FirstOrDefault();
                        if (v != null)
                        {
                            v.LabNo = com.LabNo;
                            v.floor = com.floor;
                        }
                        else
                        {
                            //Save
                            dc.labs.Add(com);
                        }
                    }

                    dc.SaveChanges();
                    status = true;
                }
            }
            return(new JsonResult {
                Data = new { status = status, message = "Saved Successfully" }
            });
        }
Exemplo n.º 4
0
        //rempve lab
        public void deletelab(int id)
        {
            lab labtodelete = db.labs.Where(a => a.lab_id == id).FirstOrDefault();

            db.labs.Remove(labtodelete);
            db.SaveChanges();
        }
        public ActionResult DeleteConfirmed(int id)
        {
            lab lab = db.labs.Find(id);

            db.labs.Remove(lab);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 6
0
        public IActionResult Deletelab(int id)
        {
            lab lab = _repo.labs.GetById(id);

            _repo.labs.Delete(id);

            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "lab_id,patient_id,test_name,test_cost")] lab lab)
 {
     if (ModelState.IsValid)
     {
         db.Entry(lab).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(lab));
 }
Exemplo n.º 8
0
 public course GetCourseOfLab(int id)
 {
     using (se02team06 context = new se02team06()) {
         DbSet <lab> dbsetLab = context.Set <lab>();
         lab         labTmp   = dbsetLab.Find(id);
         context.Entry(labTmp).Reference(s => s.course).Load();
         context.SaveChanges();
         return(labTmp.course);
     }
 }
Exemplo n.º 9
0
 public List <student> GetStudentsOfLab(int id)
 {
     using (se02team06 context = new se02team06()) {
         DbSet <lab> dbsetLab = context.Set <lab>();
         lab         labTmp   = dbsetLab.Find(id);
         context.Entry(labTmp).Collection(s => s.students).Load();
         context.SaveChanges();
         return(labTmp.students.ToList());
     }
 }
        public ActionResult Create([Bind(Include = "lab_id,patient_id,test_name,test_cost")] lab lab)
        {
            if (ModelState.IsValid)
            {
                db.labs.Add(lab);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(lab));
        }
Exemplo n.º 11
0
 private void FillLabs()
 {
     courseNames.ForEach(course => {
         labNumber.ForEach(lab => {
             lab tmpLab = new lab {
                 labNumber = labNumber[labNumber.IndexOf(lab)]
             };
             labsDbset.AddLab(tmpLab, courseNames.IndexOf(course) + 1);
         });
     });
 }
Exemplo n.º 12
0
        // update data
        public void updateLab(labVM labvm)
        {
            lab labtoupdate = db.labs.Where(a => a.lab_id == labvm.lab_id).FirstOrDefault();

            labtoupdate.lab_name     = labvm.lab_name;
            labtoupdate.lab_number   = labvm.lab_number;
            labtoupdate.description  = labvm.description;
            labtoupdate.floor_number = labvm.floor_number;
            labtoupdate.service_id   = labvm.service_id;
            db.SaveChanges();
        }
Exemplo n.º 13
0
        public IActionResult Postlab([FromBody] lab lab)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.labs.Insert(lab);

            return(CreatedAtAction("Getlab", new { id = lab.id }, lab));
        }
Exemplo n.º 14
0
 public void AddStudToLab(student student, lab lab)
 {
     using (se02team06 context = new se02team06()) {
         DbSet <student> dbsetStudent = context.Set <student>();
         DbSet <lab>     dbsetLab     = context.Set <lab>();
         var             tmpStud      = dbsetStudent.Find(student.studentID);
         var             tmpLab       = dbsetLab.Find(lab.labID);
         tmpStud.labs.Add(tmpLab);
         context.SaveChanges();
     }
 }
Exemplo n.º 15
0
 public lab AddLab(lab lab, int id)
 {
     using (se02team06 context = new se02team06()) {
         DbSet <lab>    dbsetLab    = context.Set <lab>();
         DbSet <course> dbsetCourse = context.Set <course>();
         lab.course_courseID = id;
         lab tmplab = dbsetLab.Add(lab);
         context.SaveChanges();
         return(tmplab);
     }
 }
Exemplo n.º 16
0
 private void FillLabs()
 {
     courseNames.ForEach(course => {
         labNumber.ForEach(lab => {
             lab tmpLab = new lab {
                 labNumber = labNumber[labNumber.IndexOf(lab)]
             };
             labsDbset.AddLab(tmpLab, courseNames.IndexOf(course) + 1);
         });
     });
     Console.WriteLine("- - - - - - - Finished - - - - -");
 }
Exemplo n.º 17
0
        //adding a lab
        public void AddLab(labVM labVM)
        {
            lab labToAdd = new lab();

            labToAdd.lab_name     = labVM.lab_name;
            labToAdd.lab_number   = labVM.lab_number;
            labToAdd.description  = labVM.description;
            labToAdd.floor_number = labVM.floor_number;
            labToAdd.service_id   = labVM.service_id;

            db.labs.Add(labToAdd);
            db.SaveChanges();
        }
        // GET: labs/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            lab lab = db.labs.Find(id);

            if (lab == null)
            {
                return(HttpNotFound());
            }
            return(View(lab));
        }
Exemplo n.º 19
0
        public IActionResult AddEditLab(int?id)
        {
            lab model = new lab();

            if (id.HasValue)
            {
                lab lab = _repo.labs.GetById(id.Value);
                if (lab != null)
                {
                    model = lab;
                }
            }
            return(View(model));
        }
Exemplo n.º 20
0
 public ActionResult Delete(int id)
 {
     using (TCMSDBEntities dc = new TCMSDBEntities())
     {
         lab aa = new lab();
         var v  = dc.labs.Where(a => a.LabNo == id).FirstOrDefault();
         if (v != null)
         {
             return(View(v));
         }
         else
         {
             return(HttpNotFound());
         }
     }
 }
Exemplo n.º 21
0
        public Lab ConvertLab(lab l)
        {
            Lab labor = new Lab {
                LabID           = l.labID,
                LabNumber       = l.labNumber,
                Course_courseID = l.course_courseID,
                Course          = new Course(),
                Labdates        = new List <Labdate>(),
                Tasks           = new List <Tasks>(),
                Students        = new List <Student>(),

                //new Property for UI
                LabDateCount = Context.GetLabdatesOfLab(l.labID).Count,
                StudentCount = Context.GetStudentsOfLab(l.labID).Count
            };

            return(labor);
        }
Exemplo n.º 22
0
        // get lab by id

        public labVM getLabById(int id)
        {
            lab   mylab = db.labs.Where(a => a.lab_id == id).FirstOrDefault();
            labVM labvm = new labVM();

            if (mylab != null)
            {
                labvm.lab_id       = mylab.lab_id;
                labvm.lab_name     = mylab.lab_name;
                labvm.description  = mylab.description;
                labvm.floor_number = mylab.floor_number;
                labvm.service_id   = mylab.service_id;
                labvm.lab_number   = mylab.lab_number;
                return(labvm);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 23
0
        private void RemoveStudFromLab(student s, lab l)
        {
            // delete old presents of student
            context.GetLabdatesOfLab(LabID).ForEach(ld => {
                context.GetPresentsOfLabdate(ld.labdateID)
                .Where(p => p.student_studentID == s.studentID)
                .ToList()
                .ForEach(p => {
                    dataAccess.PresentContext.Remove(p.presentID);
                });
            });

            // delete old taskDones of student
            context.GetTasksOfLab(LabID).ForEach(t => {
                context.GetTaskDonesOfTask(t.taskID)
                .Where(tD => tD.student_studentID == s.studentID)
                .ToList()
                .ForEach(tD => {
                    dataAccess.TaskDoneContext.Remove(tD.taskDoneID);
                });
            });

            context.RemoveStudFromLab(s, l);
        }
Exemplo n.º 24
0
        public IActionResult Putlab([FromRoute] int id, [FromBody] lab lab)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != lab.id)
            {
                return(BadRequest());
            }

            lab.id = id;
            _context.labs.Update(lab);



            if (!labExists(id))
            {
                return(NotFound());
            }

            return(NoContent());
        }
Exemplo n.º 25
0
        public IActionResult Details(int id)
        {
            lab lab = _repo.labs.GetById(id);

            return(View(lab));
        }
Exemplo n.º 26
0
        // Update lab object in db with user input
        private void UpdateLabDetails()
        {
            if (SelectedLabNumber != 0 &&
                SelectedStartYear != 0 &&
                SelectedStartMonth != "" &&
                SelectedStartDay != 0 &&
                SelectedLabDuration != 0 &&
                SelectedTaskNumber != 0)
            {
                // update lab

                //how much task in lab
                int taskCount = 0;

                if (SelectedLabDuration < SelectedTaskNumber)
                {
                    OpenError("Zu Viele Aufgaben für die Anzahl der Wochen.");
                    return;
                }

                taskCount = SelectedTaskNumber;

                lab updatedLab = new lab {
                    labID           = LabID,
                    course_courseID = CourseID,
                    labNumber       = SelectedLabNumber
                };

                dataAccess.LabContext.Update(LabID, updatedLab);

                //new startDate
                DateTime newStartDate = new DateTime(
                    SelectedStartYear,
                    CourseDetailViewModel.ConvertMonthToInt(SelectedStartMonth),
                    SelectedStartDay,
                    SelectedStartHour,
                    SelectedStartMinutes,
                    0);
                DateTime tmpDate = newStartDate;

                //Delete Old Labdates
                List <labdate> oldLabdates = dataAccess.Context.GetLabdatesOfLab(LabID);
                foreach (var labdate in oldLabdates)
                {
                    dataAccess.LabDateContext.Remove(labdate.labdateID);
                }

                //Create New Labdates
                for (int i = 0; i < SelectedLabDuration; i++)
                {
                    //make new labdate
                    labdate labdate = new labdate {
                        date      = tmpDate,
                        lab_labID = LabID
                    };
                    //Each Week
                    tmpDate = tmpDate.AddDays(7);

                    //Add labdate
                    dataAccess.LabDateContext.AddOne(labdate);
                }
                var newLabdates = dataAccess.Context.GetLabdatesOfLab(LabID);

                //delete old tasks
                List <task> oldTasks = dataAccess.Context.GetTasksOfLab(LabID);
                foreach (var task in oldTasks)
                {
                    dataAccess.TaskContext.Remove(task.taskID);
                }

                //Create new Tasks

                for (int i = 0; i < taskCount; i++)
                {
                    //make new Task
                    task newTask = new task {
                        taskNumber = i + 1,
                        dueDate    = newLabdates[i].date,
                        lab_labID  = LabID,
                    };

                    //Add task
                    dataAccess.TaskContext.AddOne(newTask);
                }
                var studentInLab = context.GetStudentsOfLab(LabID);
                var allLabdates  = context.GetLabdatesOfLab(LabID);
                var alltask      = context.GetTasksOfLab(LabID);

                studentInLab.ForEach(student => {
                    alltask.ForEach(task => {
                        taskdone newTask = new taskdone {
                            student_studentID = student.studentID,
                            isDone            = 0,
                            task_taskID       = task.taskID
                        };
                        dataAccess.TaskDoneContext.AddOne(newTask);
                    });

                    allLabdates.ForEach(dates => {
                        present newPresent = new present {
                            note              = "",
                            wasPresent        = 0,
                            student_studentID = student.studentID,
                            labdate_labdateID = dates.labdateID
                        };
                        dataAccess.PresentContext.AddOne(newPresent);
                    });
                });

                //Update courseDetailPage
                LabDateCount = newLabdates.Count;
                LabHour      = newLabdates.First().date.Hour;
                LabMinute    = newLabdates.First().date.Minute;
                LabWeekday   = newLabdates.First().date.DayOfWeek.ToString();
                LabNumber    = "Labornummer: " + SelectedLabNumber.ToString();;
                LabTime      = $"{LabWeekday}, {LabHour}:{LabMinute}";

                RefreshCourseDetailView();

                FillAll();

                // Change visibility of lab
                EditLabViewVisible ^= true;
                Console.WriteLine();
            }
            ;
        }
Exemplo n.º 27
0
 public Controller(lab <Technics> Product)
 {
     obj = Product;
 }