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; }
public Modules(ELearning semester) { try { DisplayContent(semester); } catch (Exception ex) { DisplayError(ex); } }
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)); }
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)); }
public AdminController() { db = new ELearning(); }
public StudentController() { db = new ELearning(); }
public ProfessorController() { db = new ELearning(); }
public HomeController() { db = new ELearning(); }
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)); }