Exemplo n.º 1
0
        public async Task <ActionResult> Edit(DepartmentViewModel model)
        {
            if (ModelState.IsValid)
            {
                Department modeldepartment = DepartmentFactory.ViewModelToDepartmentEntity(model);


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

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



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

                if (department != null)
                {
                    _dbContext.Departments.Add(department);
                }
                await _dbContext.SaveChangesAsync();

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



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