コード例 #1
0
ファイル: CategoriesController.cs プロジェクト: f7deat/MotCua
        public async Task <ActionResult> Create([Bind(Include = "CategoryId,CategoryName,Decription")] Category category)
        {
            if (ModelState.IsValid)
            {
                db.Categories.Add(category);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(category));
        }
コード例 #2
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            Department department = await db.Departments.FindAsync(id);

            db.Departments.Remove(department);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
コード例 #3
0
        public async Task <ActionResult> Create([Bind(Include = "UserId,Password,FacultyId,GroupId,FullName,DateOfBirth,Gender,Address,Email,PhoneNumber,CreatedDate,Image,Status")] User user)
        {
            if (ModelState.IsValid)
            {
                db.Users.Add(user);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            ViewBag.FacultyId = new SelectList(_facultyService.GetAll(), "FacultyId", "FacultyName", user.FacultyId);
            ViewBag.GroupId   = new SelectList(_groupService.GetAll(), "GroupId", "GroupName", user.GroupId);
            return(View(user));
        }