Example #1
0
    public void UpdateRoomsAtBranch(int roomID, IList <BranchRoomCapacityViewModel> branchesID)
    {
        foreach (var item in ctx.ActiveClassRoomInBranches.Where(room => room.ClassRoomID == roomID))
        {
            ctx.ActiveClassRoomInBranches.DeleteOnSubmit(item);
        }

        foreach (var item in branchesID)
        {
            ActiveClassRoomInBranch room = new ActiveClassRoomInBranch();
            room.ClassRoomID = roomID;
            room.BranchID    = item.BranchID;
            room.Capacity    = Convert.ToInt16(item.Capacity);
            ctx.ActiveClassRoomInBranches.InsertOnSubmit(room);
        }

        ctx.SubmitChanges();
    }
Example #2
0
        public void UpdateRoomsAtBranch(int roomID, IList <BranchRoomCapacityViewModel> branchesID)
        {
            foreach (var item in context.ActiveClassRoomInBranches.Where(room => room.ClassRoomID == roomID))
            {
                context.Delete(item);
            }

            foreach (var item in branchesID)
            {
                ActiveClassRoomInBranch room = new ActiveClassRoomInBranch();
                room.ClassRoomID = roomID;
                room.BranchID    = item.BranchID;
                room.Capacity    = Convert.ToInt16(item.Capacity);
                context.Add(room);
            }

            context.SaveChanges();
        }