コード例 #1
0
        /// <summary>
        /// Update a class room
        /// </summary>
        /// <param name="classRoomId">Id of the class room</param>
        /// <param name="editClassRoom">Updated details of the class room</param>
        /// <returns></returns>
        public async Task<ClassRoom> UpdateClassRoom(Guid classRoomId, EditClassRoom editClassRoom)
        {
            if (classRoomId.IsNullOrEmpty())
                throw new ArgumentNullException(nameof(classRoomId));

            if (editClassRoom == null)
                throw new ArgumentNullException(nameof(editClassRoom));

            return await _classRoomRepo.Update(classRoomId, editClassRoom);
        }
コード例 #2
0
        public async Task<ClassRoom.ClassRoom> Update(Guid id, EditClassRoom editItem)
        {
            var item = await _db.ClassRooms.FirstOrDefaultAsync(c => c.Id == id);
            if(item != null)
            {
                editItem.UpdateClassRoomFields(item);
                
                _db.ClassRooms.Update(item);
                await _db.SaveChangesAsync();
            }

            return item;
        }