public async Task <BranchClass> CreateBranchClass(BranchClass BranchClass)
        {
            if (BranchClass.Id == 0)
            {
                _context.BranchClass.Add(BranchClass);
            }
            try
            {
                await _context.SaveChangesAsync();

                return(BranchClass);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public async Task <BranchClass> CreateBranchClass(BranchClass branchClass)
        {
            var branchClassExist = _context.BranchClass.Where(b => b.BranchId == branchClass.BranchId &&
                                                              b.ShiftId == branchClass.ShiftId &&
                                                              b.SchoolVersionId == branchClass.SchoolVersionId &&
                                                              b.SchoolClassId == branchClass.SchoolClassId).FirstOrDefault();

            if (branchClass.Id == 0 && branchClassExist == null && branchClass.SchoolClassId != 0)
            {
                _context.BranchClass.Add(branchClass);
            }
            try
            {
                await _context.SaveChangesAsync();

                return(branchClass);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public async Task <BranchClass> UpdateBranchClass(int id, BranchClass BranchClass)
        {
            BranchClass clr = _context.BranchClass.Find(BranchClass.Id);

            if (clr != null)
            {
                //Update that educationSystem
                clr.BranchId      = BranchClass.BranchId;
                clr.SchoolClassId = BranchClass.SchoolClassId;

                _context.BranchClass.Update(clr);
            }
            try
            {
                var result = await _context.SaveChangesAsync();

                return(BranchClass);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }