Exemple #1
0
 public IActionResult Create(CourseViewModel model)
 {
     if (ModelState.IsValid)
     {
         var course = context.Courses.Add(new Course()
         {
             Name         = model.Name,
             User         = context.Users.Where(u => u.UserName.Equals(User.Identity.Name)).FirstOrDefault(),
             Rating       = new Random().Next(1, 100) / 10,
             Bibliography = model.Bibliography,
             HomeTask     = model.HomeTask,
             Descript     = model.Description,
             Dificult     = Int32.Parse(model.Dificult),
             Price        = Double.Parse(model.Price)
         });
         context.SaveChanges();
         return(RedirectToAction("Index", "Profile"));
     }
     return(View(model));
 }
 public void Save()
 {
     context.SaveChanges();
 }