public ActionResult Create([Bind(Include = "DesignationId,DesignationName")] Designation designation)
        {
            if (ModelState.IsValid)
            {
                db.DesignationDbSet.Add(designation);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(designation));
        }
Exemple #2
0
        public ActionResult Create([Bind(Include = "SemisterId,SemisterName")] Semister semister)
        {
            if (ModelState.IsValid)
            {
                db.SemisterDbSet.Add(semister);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(semister));
        }
        public ActionResult Create([Bind(Include = "DepartmentId,Code,Name")] Department department)
        {
            if (ModelState.IsValid)
            {
                db.DepartmentDbSet.Add(department);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(department));
        }
        public ActionResult Create([Bind(Include = "CourseId,CourseCode,CourseCredit,CourseName,Description,DepartmentId,SemisterId")] Course course)
        {
            if (ModelState.IsValid)
            {
                db.CourseDbSet.Add(course);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.DepartmentId = new SelectList(db.DepartmentDbSet, "DepartmentId", "Code", course.DepartmentId);
            ViewBag.SemisterId   = new SelectList(db.SemisterDbSet, "SemisterId", "SemisterName", course.SemisterId);
            return(View(course));
        }
        public ActionResult Create([Bind(Include = "TeacherId,TeacherName,TeacherAddress,TeacherEmail,ContactNo,DesignationId,TeacherCredit,DepartmentId")] Teacher teacher)
        {
            if (ModelState.IsValid)
            {
                db.TeacherDbSet.Add(teacher);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.DepartmentId  = new SelectList(db.DepartmentDbSet, "DepartmentId", "Code", teacher.DepartmentId);
            ViewBag.DesignationId = new SelectList(db.DesignationDbSet, "DesignationId", "DesignationName", teacher.DesignationId);
            return(View(teacher));
        }
 public void SaveApply(Place model)
 {
     using (var context = new UniDbContext())
     {
         context.Places.Add(model);
         context.SaveChanges();
     }
 }
 private App()
 {
     using (UniDbContext db = new UniDbContext())
     {
         Group group = new Group()
         {
             Name = "Best Group"
         };
         Student student = new Student()
         {
             Name    = "Elvin",
             Surname = "Camalzade",
             GroupId = 1
         };
         db.Groups.Add(group);
         db.Students.Add(student);
         db.SaveChanges();
     }
 }
Exemple #8
0
        private void SynchronizePermissions()
        {
            using (var transaction = _uniDbContext.Database.BeginTransaction(IsolationLevel.ReadCommitted))
            {
                try
                {
                    var permissions = AuthorizationConfiguration.GetPermissions(typeof(Permissions));

                    var currentPermissions = _uniDbContext.Permissions.ToHashSet();

                    var newPermissions = permissions
                                         .Where(
                        x => !currentPermissions.Any(
                            y => string.Equals(x, y.Name, StringComparison.OrdinalIgnoreCase)
                            )
                        ).Select(x => new Permission {
                        Name = x
                    }).ToArray();

                    if (newPermissions.Length != 0)
                    {
                        _logger.LogInformation($"Found {newPermissions.Length} new permissions.");
                        _uniDbContext.Permissions.AddRange(newPermissions);
                        _uniDbContext.SaveChanges();
                    }
                    else
                    {
                        _logger.LogInformation("No permissions were added. The database is already up to date.");
                    }

                    transaction.Commit();
                }
                catch
                {
                    transaction.Rollback();
                    throw;
                }
            }
        }