Exemplo n.º 1
0
        public IActionResult RequestPpe([FromServices] DataContext dataContext, NeedsViewModel vm)
        {
            SimpleNotifier noty = notifier();

            if (ModelState.IsValid)
            {
                Need need = Need.CreateFromViewModel(vm);
                dataContext.Needs.Add(need);
                dataContext.SaveChanges(currentUserName);
                noty.AddMessage(MsgTypes.Success, "Thanks you have been added to the database, we will be in contact in due course");
                return(Redirect("/"));
            }
            else
            {
                noty.AddMessage(MsgTypes.Warning, "Problems saving details, please fix and try again");
                return(View(vm));
            }
        }