public async Task <ActionResult> Create([Bind(Include = "StudentId,CardNumber,StudentName,Sex,NationId,Birthday,CNumber,NativePlace,TelNumber,SchoolName,Adress,ZipCode,Patriarch,Pat_Telnum,Mandator,UnifiedScore,TotalPoints,SpecialtyId,Period_CategoryId,StudentAccId")] Student student)
        {
            if (Session["Acc"] != null)
            {
                string myacc = Session["Acc"].ToString();
                if (ModelState.IsValid)
                {
                    student.Period_CategoryId = 1;
                    StudentAcc sacc = await db.StudentAccs.Where(s => s.StuAcc == myacc).FirstOrDefaultAsync();

                    student.StudentAccId = sacc.StudentAccId;
                    student.Time         = DateTime.Now;
                    db.Students.Add(student);
                    await db.SaveChangesAsync();

                    return(RedirectToAction("Index", "Home"));
                }
                ViewBag.NationId    = new SelectList(db.Nations, "NationId", "NationName", student.NationId);
                ViewBag.SpecialtyId = new SelectList(db.Specialtys.Where(s => s.Period_CategoryId == 1), "SpecialtyId", "SpecialtyName", student.SpecialtyId);
            }
            else
            {
                return(RedirectToAction("Index", "Home"));
            }

            return(View(student));
        }
        public async Task <ActionResult> Create([Bind(Include = "StudentAccId,StuAcc,Password")] StudentAcc studentAcc)
        {
            if (ModelState.IsValid)
            {
                db.StudentAccs.Add(studentAcc);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(studentAcc));
        }
Exemplo n.º 3
0
        public async Task <ActionResult> Create([Bind(Include = "Id,AdminName,Password")] SysAdmin sysAdmin)
        {
            if (ModelState.IsValid)
            {
                db.SysAdmins.Add(sysAdmin);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(sysAdmin));
        }
Exemplo n.º 4
0
        public async Task <ActionResult> Create([Bind(Include = "SpecialtyId,SpecialtyName,Period_CategoryId,Tuition")] Specialty specialty)
        {
            if (ModelState.IsValid)
            {
                db.Specialtys.Add(specialty);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            ViewBag.Period_CategoryId = new SelectList(db.Period_Categorys, "Period_CategoryId", "CategoryName", specialty.Period_CategoryId);
            return(View(specialty));
        }