Exemplo n.º 1
0
        public ActionResult Create(RaterCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var service = CreateRaterService();

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

            ModelState.AddModelError("", "Rater information could not be created");
            return(View(model));
        }
Exemplo n.º 2
0
        public bool CreateRater(RaterCreate model)
        {
            Rater rater = new Rater()
            {
                OwnerID  = _userID,
                Branch   = model.Branch,
                Job      = model.Job,
                Rank     = model.Rank,
                Age      = model.Age,
                UserName = GetUserName()
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Raters.Add(rater);
                return(ctx.SaveChanges() == 1);
            }
        }