예제 #1
0
 public void AddAdmin(POCO.Admin pocoAdmin, ref List<string> errors)
 {
     admin db_Admin = new admin();
     try
     {
         db_Admin.First = pocoAdmin.FirstName;
         db_Admin.Last = pocoAdmin.LastName;
         this.context.admins.Add(db_Admin);
         this.context.SaveChanges();
     }
     catch (Exception e)
     {
         errors.Add("Error occured in AdminRepository.AddAdminById: " + e);
     }
 }
예제 #2
0
        ////good method for validation when adding new course
        public bool IsNotDuplicateAdmin(POCO.Admin adminPoco, ref List<string> errors)
        {
            var db_Admin = new admin();

            try
            {
                db_Admin = this.context.admins.Find(db_Admin);

                if (db_Admin == null)
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
            catch (Exception e)
            {
                errors.Add("Error occured in AdminRepository.IsDuplicateAdmin: " + e);
            }

            return true;
        }
예제 #3
0
        public void UpdateAdmin(POCO.Admin adminPoco, ref List<string> errors)
        {
            var db_Admin = new admin();

            try
            {
                db_Admin = this.context.admins.Find(adminPoco.Id);
                db_Admin.First = adminPoco.FirstName;
                db_Admin.Last = adminPoco.LastName;
                this.context.SaveChanges();
            }
            catch (Exception e)
            {
                errors.Add("Error occured in AdminRepository.UpdateAdmin: " + e);
            }
        }
예제 #4
0
        public void RemoveAdmin(int admin_id, ref List<string> errors)
        {
            var db_Admin = new admin();

            try
            {
                db_Admin.admin_id = admin_id;
                db_Admin = this.context.admins.Remove(db_Admin);
                this.context.SaveChanges();
            }
            catch (Exception e)
            {
                errors.Add("Error occured in TaRepository.FindTaById: " + e);
            }
        }