Example #1
0
        public bool CreateHelp(HelpCreate model)
        {
            var ctx      = new ApplicationDbContext();
            var provider = new Provider()
            {
                Name    = model.Name,
                Company = model.Company,
                Email   = model.Email,
                Phone   = model.Phone,
            };

            ctx.Providers.Add(provider);

            var help = new Help()
            {
                OwnerId     = _userID,
                Category    = model.Category,
                Subcategory = model.Subcategory,
                Experience  = model.Experience,
                Rate        = model.Rate,
                NewClients  = model.NewClients,
            };

            ctx.Helps.Add(help);

            return(ctx.SaveChanges() >= 1);
        }
Example #2
0
        public ActionResult Create(HelpCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var service = CreateHelpService();

            if (service.CreateHelp(model))
            {
                TempData["SaveResult"] = "Help created successfully.";
                return(RedirectToAction("Index"));
            }
            ;
            ModelState.AddModelError("", "Help could not be created.");
            return(View(model));
        }