Exemplo n.º 1
0
        public async Task <ActionResult> Edit(MottorModelViewModel model)
        {
            if (ModelState.IsValid)
            {
                MottorModel modelDriver = MottoModelFactory.ViewModelToMottoEntity(model);

                _dbContext.Entry(modelDriver).State = EntityState.Modified;
                await _dbContext.SaveChangesAsync();

                Success("Model Updated Successfully", true);
                return(Json(new { success = true }));
            }

            return(PartialView("_Edit", model));
        }
Exemplo n.º 2
0
        public async Task <ActionResult> Create(MottorModelViewModel model)
        {
            //Check the validity of the model
            if (ModelState.IsValid)
            {
                // call an instance of Driver Class
                var driver = MottoModelFactory.ViewModelToMottoEntity(model);

                _dbContext.MottoModels.Add(driver);
                await _dbContext.SaveChangesAsync();

                Success("Creted Successfully", true);
                return(Json(new { success = true }));
            }



            return(PartialView("_Create", model));;
        }