Exemplo n.º 1
0
        public async Task <SharedLookUpResponse> UpdateComponentAsync(UpdateRoomType updateComponentAc, int instituteId)
        {
            var componentGroups = await iMSDbContext.RoomTypes.Where(x => x.InstituteId == instituteId && x.Id != updateComponentAc.Id).ToListAsync();

            var isDuplicated = componentGroups.Any(x => x.Code.ToLowerInvariant() == updateComponentAc.Code.ToLowerInvariant());

            if (isDuplicated)
            {
                return new SharedLookUpResponse()
                       {
                           HasError = true, ErrorType = SharedLookUpResponseType.Code, Message = "Duplicate Code of Room Type, please use unique code"
                       }
            }
            ;
            else
            {
                var componentGroup = await iMSDbContext.RoomTypes.FirstAsync(x => x.Id == updateComponentAc.Id);

                componentGroup.Name        = updateComponentAc.Name;
                componentGroup.Code        = updateComponentAc.Code;
                componentGroup.Description = updateComponentAc.Description;
                iMSDbContext.RoomTypes.Update(componentGroup);
                await iMSDbContext.SaveChangesAsync();

                return(new SharedLookUpResponse()
                {
                    HasError = false, Message = "Room Type updated successfully"
                });
            }
        }
Exemplo n.º 2
0
        public async Task <IActionResult> UpdateGroupAsync([FromBody] UpdateRoomType updateComponentGroupAc)
        {
            if (string.IsNullOrEmpty(updateComponentGroupAc.Name.Trim()))
            {
                return(Ok(new SharedLookUpResponse()
                {
                    HasError = true,
                    ErrorType = SharedLookUpResponseType.Name,
                    Message = "Room Type name can't be null or empty"
                }));
            }
            else if (string.IsNullOrEmpty(updateComponentGroupAc.Code.Trim()))
            {
                return(Ok(new SharedLookUpResponse()
                {
                    HasError = true,
                    ErrorType = SharedLookUpResponseType.Name,
                    Message = "Room Type code can't be null or empty"
                }));
            }
            else
            {
                var instituteId = await GetUserCurrentSelectedInstituteIdAsync();

                if (await iMSDbContext.RoomTypes.AnyAsync(x => x.Id == updateComponentGroupAc.Id && x.InstituteId == instituteId))
                {
                    return(Ok(await roomTypeManagement.UpdateComponentAsync(updateComponentGroupAc, instituteId)));
                }
                else
                {
                    return(Ok(new SharedLookUpResponse()
                    {
                        HasError = true, ErrorType = SharedLookUpResponseType.Code, Message = "Room Type not found"
                    }));
                }
            }
        }
Exemplo n.º 3
0
        private void NotifyPlayersAboutUpdateRoom(ClientObject client, RoomObject room, UpdateRoomType type)
        {
            var response = new UpdateRoomResponse();

            if (type == UpdateRoomType.UpdatePlayers)
            {
                response.Type     = UpdateRoomType.UpdatePlayers;
                response.Player   = client.Player;
                response.Selector = room.Selector.Player;
                if (room.Respondent != null)
                {
                    response.Respondent = room.Respondent.Player;
                }
            }
            else
            {
                response.Type = UpdateRoomType.UpdateTable;
                room.Game.StopAnswerButtonClickTimer();
            }
            string packetResponse = JsonConvert.SerializeObject(response);

            //после отправки удаляем респондента
            room.Respondent = null;
            room.SendMessageToAllClients(packetResponse);
        }