Ejemplo n.º 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);
     }
 }
Ejemplo n.º 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;
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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);
            }
        }