Exemplo n.º 1
0
        public async Task <SubScreenForReturnDto> Create(SubScreenForCreationDto createDto)
        {
            var checkByNameFormRepo = await subScreenDal.GetAsync(x => x.Name.ToLower() == createDto.Name.ToLower());

            if (checkByNameFormRepo != null)
            {
                throw new RestException(HttpStatusCode.BadRequest, new { AlreadyExist = Messages.AlreadyExist });
            }

            var getByScreenId = await subScreenDal.GetListAsync(x => x.ScreenId == createDto.ScreenId);

            if (getByScreenId.Count() >= 3)
            {
                throw new RestException(HttpStatusCode.BadRequest, new { ExceedScreenSize = "En fazla 3 alt ekran olmalı..." });
            }

            if (createDto.Height > 100 || createDto.Width > 100)
            {
                throw new RestException(HttpStatusCode.BadRequest, new { ExceedScreenSize = "Alt Ekranın Genişlik/Yükseklik'lerinin toplamı en fazla 100 olmalı" });
            }

            var mapForCreate = mapper.Map <SubScreen>(createDto);
            var saveToDb     = await subScreenDal.Add(mapForCreate);

            var mapForReturn = mapper.Map <SubScreen, SubScreenForReturnDto>(saveToDb);

            return(mapForReturn);
        }
        public async Task <ActionResult <SubScreenForReturnDto> > Update(SubScreenForCreationDto updateDto)
        {
            var subscreen = await subScreenService.Update(updateDto);

            var onlineScreens = await onlineScreenService.GetOnlineScreenConnectionIdByScreenId(subscreen.ScreenId);

            if (onlineScreens != null && onlineScreens.Length != 0)
            {
                await kiosksHub.Clients.Clients(onlineScreens).SendAsync("ReceiveSubScreen", subscreen);
            }
            return(subscreen);
        }
Exemplo n.º 3
0
        public async Task <SubScreenForReturnDto> Update(SubScreenForCreationDto updateDto)
        {
            var checkById = await subScreenDal.GetAsync(x => x.Id == updateDto.Id);

            if (checkById == null)
            {
                throw new RestException(HttpStatusCode.BadRequest, new { NotFound = Messages.NotFound });
            }

            if (updateDto.Height > 100 || updateDto.Width > 100)
            {
                throw new RestException(HttpStatusCode.BadRequest, new { ExceedScreenSize = "Alt Ekranın Genişlik/Yükseklik'lerinin toplamı en fazla 100 olmalı" });
            }


            var mapForUpdate = mapper.Map(updateDto, checkById);
            var updateToDb   = await subScreenDal.Update(mapForUpdate);

            return(mapper.Map <SubScreen, SubScreenForReturnDto>(mapForUpdate));
        }