示例#1
0
        public bool CreateAlgorithm(AlgorithmCreate model)
        {
            var entity =
                new Algorithm()
            {
                OwnerId           = _userId,
                LearningAlgorithm = model.LearningAlgorithm,
                MasteryLevel      = model.MasteryLevel,
                CreatedUtc        = DateTimeOffset.Now
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Algorithms.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
示例#2
0
        public ActionResult Create(AlgorithmCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var service = CreateAlgorithmService();

            if (service.CreateAlgorithm(model))
            {
                TempData["SaveResult"] = "Your algorithm was created.";
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "Algorithm could not be created.");

            return(View(model));
        }