예제 #1
0
        public void DisplayContent(ELearning semester)
        {
            base.DisplayContent(Data);

            Title = "Semestre " + semester.Semester;
            var modules = new List <ModuleElearning> (semester.Dic.Values);

            ListView list = new ListView {
                ItemTemplate = new DataTemplate(typeof(TextCell))
                {
                    Bindings =
                    {
                        { TextCell.TextProperty,   new Binding("Title") },
                        { TextCell.DetailProperty, new Binding("InnerCount")
                                                    {
                                                        StringFormat = "{0} Cour(s) et TP(s)"
                                                    } }
                    }
                },
                ItemsSource = modules
            };

            list.ItemSelected += async(sender, e) => {
                if (e.SelectedItem == null)
                {
                    return;
                }
                await Navigation.PushAsync(new Classes (((ModuleElearning)e.SelectedItem)));

                list.SelectedItem = null;
            };

            Content = list;
        }
예제 #2
0
 public Modules(ELearning semester)
 {
     try {
         DisplayContent(semester);
     } catch (Exception ex) {
         DisplayError(ex);
     }
 }
예제 #3
0
        public async Task <IActionResult> Create(ELearningViewModel eLearningViewModel)
        {
            if (ModelState.IsValid)
            {
                string file1 = "No File";
                string file2 = "No File";
                if (eLearningViewModel.ELearningFile1 != null)
                {
                    string uniqueFileName = null;
                    string stringCutted   = eLearningViewModel.ELearningFile1.FileName.Split('.').Last();
                    uniqueFileName = Guid.NewGuid().ToString() + "." + stringCutted;
                    file1          = uniqueFileName;
                    InputFile fileUpload = new InputFile(_hostingEnvironment);
                    fileUpload.Uploadfile("files/e_learnings", eLearningViewModel.ELearningFile1, file1);
                }
                if (eLearningViewModel.ELearningFile2 != null)
                {
                    string uniqueFileName = null;
                    string stringCutted   = eLearningViewModel.ELearningFile2.FileName.Split('.').Last();
                    uniqueFileName = Guid.NewGuid().ToString() + "." + stringCutted;
                    file2          = uniqueFileName;
                    InputFile fileUpload = new InputFile(_hostingEnvironment);
                    fileUpload.Uploadfile("files/e_learnings", eLearningViewModel.ELearningFile2, file2);
                }

                var loggedInUser = await _userManager.FindByNameAsync(HttpContext.User.Identity.Name);

                var eLearning = new ELearning
                {
                    FactoryId          = loggedInUser.FactoryId,
                    Description        = eLearningViewModel.Description,
                    DateOfUpload       = eLearningViewModel.DateOfUpload,
                    ELearningFileName1 = file1,
                    ELearningFileName2 = file2
                };

                _context.Add(eLearning);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(eLearningViewModel));
        }
예제 #4
0
        public ContentResult Save(int?id, FormCollection actionValues)
        {
            var action       = new DataAction(actionValues);
            var changedEvent = DHXEventsHelper.Bind <Event>(actionValues);
            var entities     = new ELearning();

            //try
            //{
            switch (action.Type)
            {
            case DataActionTypes.Insert:
                entities.Events.Add(changedEvent);
                break;

            case DataActionTypes.Delete:
                changedEvent = entities.Events.FirstOrDefault(ev => ev.id == action.SourceId);
                entities.Events.Remove(changedEvent);
                break;

            default:        // "update"
                var target = entities.Events.Single(e => e.id == changedEvent.id);
                DHXEventsHelper.Update(target, changedEvent, new List <string> {
                    "id"
                });
                break;
            }
            entities.SaveChanges();
            action.TargetId = changedEvent.id;
            //}
            //catch (Exception a)
            //{
            //    action.Type = DataActionTypes.Error;
            //}

            return(new AjaxSaveResponse(action));
        }
예제 #5
0
 public AdminController()
 {
     db = new ELearning();
 }
예제 #6
0
 public StudentController()
 {
     db = new ELearning();
 }
예제 #7
0
 public ProfessorController()
 {
     db = new ELearning();
 }
예제 #8
0
 public HomeController()
 {
     db = new ELearning();
 }
예제 #9
0
        public async Task <IActionResult> Edit(int id, ELearningViewModel eLearningViewModel)
        {
            if (id != eLearningViewModel.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                InputFile fileUpload = new InputFile(_hostingEnvironment);
                var       eLearning  = new ELearning
                {
                    Id                 = eLearningViewModel.Id,
                    FactoryId          = eLearningViewModel.FactoryId,
                    Description        = eLearningViewModel.Description,
                    DateOfUpload       = eLearningViewModel.DateOfUpload,
                    ELearningFileName1 = eLearningViewModel.OldELearningFileName1,
                    ELearningFileName2 = eLearningViewModel.OldELearningFileName2
                };

                if (eLearningViewModel.ELearningFile1 != null)
                {
                    string uniqueFileName = null;
                    string stringCutted   = eLearningViewModel.ELearningFile1.FileName.Split('.').Last();
                    uniqueFileName = Guid.NewGuid().ToString() + "." + stringCutted;
                    eLearning.ELearningFileName1 = uniqueFileName;
                    if (eLearningViewModel.OldELearningFileName1.ToLower() == "no file")
                    {
                        fileUpload.Uploadfile("files/e_learnings", eLearningViewModel.ELearningFile1, uniqueFileName);
                    }
                    else
                    {
                        fileUpload.Updatefile("files/e_learnings", eLearningViewModel.ELearningFile1, eLearningViewModel.OldELearningFileName1, uniqueFileName);
                    }
                }
                if (eLearningViewModel.ELearningFile2 != null)
                {
                    string uniqueFileName = null;
                    string stringCutted   = eLearningViewModel.ELearningFile2.FileName.Split('.').Last();
                    uniqueFileName = Guid.NewGuid().ToString() + "." + stringCutted;
                    eLearning.ELearningFileName2 = uniqueFileName;
                    if (eLearningViewModel.OldELearningFileName2.ToLower() == "no file")
                    {
                        fileUpload.Uploadfile("files/e_learnings", eLearningViewModel.ELearningFile2, uniqueFileName);
                    }
                    else
                    {
                        fileUpload.Updatefile("files/e_learnings", eLearningViewModel.ELearningFile2, eLearningViewModel.OldELearningFileName2, uniqueFileName);
                    }
                }

                try
                {
                    _context.Update(eLearning);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ELearningExists(eLearning.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(eLearningViewModel));
        }