예제 #1
0
        public ViewResult create()
        {
            List <Programme> programlist = _program.GetAllProgrammes().ToList();
            batchViewModel   batchView   = new batchViewModel()
            {
                programName = programlist,
            };

            return(View(batchView));
        }
        public ViewResult update(int id)
        {
            Batch          batch     = _batchRepo.GetBatch(id);
            batchViewModel batchView = new batchViewModel()
            {
                Id         = batch.Id,
                supervisor = batch.Supervisor,
                startDate  = batch.StartDate,
                endDate    = batch.EndDate,
                BatchName  = batch.Name
            };

            return(View(batchView));
        }
 public IActionResult create(batchViewModel model)
 {
     if (ModelState.IsValid)
     {
         Batch batch = new Batch()
         {
             Name       = model.BatchName,
             Supervisor = model.Title.ToString() + ". " + model.FirstName + " " + model.LastName,
             StartDate  = model.startDate,
             EndDate    = model.endDate
         };
         _batchRepo.AddBatch(batch);
     }
     return(RedirectToAction("Index"));
 }
        public IActionResult update(batchViewModel model)
        {
            Batch batch = _batchRepo.GetBatch(model.Id);

            if (ModelState.IsValid)
            {
                batch.Supervisor = model.supervisor;
                batch.StartDate  = model.startDate;
                batch.EndDate    = model.endDate;
                batch.Name       = model.BatchName;

                _batchRepo.UpdateBatch(batch);
                return(RedirectToAction("index"));
            }
            return(View());
        }
예제 #5
0
 public IActionResult create(batchViewModel model)
 {
     if (ModelState.IsValid)
     {
         Batch batch = new Batch()
         {
             Name       = model.BatchName,
             Supervisor = model.Title.ToString() + ". " + model.FirstName + " " + model.LastName,
             StartDate  = model.startDate.Date,
             EndDate    = model.endDate.Date,
             Year       = model.startDate.Year.ToString(),
             Program_Id = int.Parse(model.selectedProgram),
             //programme = model.programName.ToString(),
         };
         _batchRepo.AddBatch(batch);
     }
     return(RedirectToAction("Index"));
 }