Beispiel #1
0
        private void btnRemoveChannel_Click(object sender, RoutedEventArgs e)
        {
            Button     senderButton = sender as Button;
            ChannelDTO channel      = senderButton.DataContext as ChannelDTO;

            channels.Remove(channel);
        }
        private async void ucChannelView_ChannelRenamed(ChannelDTO channel)
        {
            txtViewName.Text = channel.Name;
            await update();

            //selectChannel(channel.Id); TODO: Does not work
        }
Beispiel #3
0
        private void txtChannelRowName_LostFocus(object sender, RoutedEventArgs e)
        {
            TextBox    channelTextBox = sender as TextBox;
            ChannelDTO channel        = channelTextBox.DataContext as ChannelDTO;

            channel.Name = channelTextBox.Text;
        }
Beispiel #4
0
        public async Task <IHttpActionResult> GetChannel(int id)
        {
            Channel channel = await db.Channels.FindAsync(id);

            ApplicationUser user  = db.Users.Find(User.Identity.GetUserId());
            bool            isSub = channel.Subscribers.Contains(user);//.FirstOrDefault<string>(S=>S == userId);
            ChannelDTO      chan  = new ChannelDTO
            {
                Id              = channel.Channel_id,
                ChannelName     = channel.ChannelName,
                SubscriberCount = channel.SubscriberCount,
                Subscribers     = channel.Subscribers.Select(S => new UserDTOcs()
                {
                    Id       = S.Id,
                    Username = S.UserName
                }).ToList(),
                IsCurrentUserSub = isSub
            };

            if (channel == null)
            {
                return(NotFound());
            }

            return(Ok(chan));
        }
 public FeedDTO(ChannelInfo channel, IEnumerable <VideoInfo> videos, Podcast podcast, Func <string, string> fileUrlFactory)
 {
     Version = 2.0M;
     Channel = new ChannelDTO
     {
         Title       = string.IsNullOrWhiteSpace(podcast.Contains) ? channel.Title : $"{channel.Title} - {podcast.Contains}",
         Link        = channel.Url,
         Author      = channel.Title,
         Description = channel.Description,
         Summary     = channel.Description,
         Subtitle    = channel.Title,
         Image       = new ImageDTO
         {
             ImageUrl = channel.ImageUrl
         },
         Items = videos.Select(v => new ItemDTO
         {
             Title           = v.Title,
             Guid            = v.Url,
             Link            = v.Url,
             Description     = v.Description,
             Summary         = v.Description,
             Author          = channel.Title,
             Duration        = v.Duration?.ToString(),
             PublicationDate = v.PublicationDate?.ToString("r"),
             Enclosure       = new EnclosureDTO
             {
                 Url  = fileUrlFactory(v.Id),
                 Type = Constants.YouTube.AudioMimeType
             }
         }).ToArray()
     };
 }
Beispiel #6
0
 public ActionResult Index(ChannelDTO channel)
 {
     if (User.Identity.IsAuthenticated == true && channel != null)
     {
         if (channel.ChannelId == null && channel.Name == null)
         {
             UserDTO userDTO = UserService.GetUserByName(User.Identity.Name);
             userDTO.Image = null;
             return(RedirectToAction("GetChannels", userDTO));
         }
         else if (channel.ChannelId == null)
         {
             channel = channelService.GetChannelByName(channel.Name);
         }
         else if (channel.Name == null)
         {
             channel = channelService.GetChannelById(channel.ChannelId);
         }
         return(View(channel));
     }
     else
     {
         return(RedirectToAction("Login", "Account"));
     }
 }
Beispiel #7
0
        public void CanGetUserChannels()
        {
            //Arrange
            _userServiceMock.Setup(u => u.GetUserChannels(It.IsAny <string>())).Returns(new List <ChannelDTO>()
            {
                new ChannelDTO()
                {
                    ChannelId = "1", Name = "Channel1"
                },
                new ChannelDTO()
                {
                    ChannelId = "2", Name = "Channel2"
                }
            });
            ChannelDTO channelDto = new ChannelDTO();

            //Act
            var rezult = _userServiceMock.Object.GetUserChannels("1");

            foreach (var channel in rezult.Where(channel => channel.Name == "Channel2"))
            {
                channelDto = channel;
            }

            //Assert
            Assert.IsNotNull(rezult);
            Assert.IsInstanceOfType(rezult, typeof(List <ChannelDTO>));
            Assert.AreEqual("Channel2", channelDto.Name);
        }
        public async Task <IActionResult> Put(ChannelDTO Channel)
        {
            var isUpdated = await _ChannelService.UpdateChannel(Channel);

            var response = new ApiResponse <bool>(isUpdated);

            return(Ok(response));
        }
        public async Task <IActionResult> GetChannel(int id)
        {
            ChannelDTO Channel = await _ChannelService.GetChannel(id);

            var response = new ApiResponse <ChannelDTO>(Channel);

            return(Ok(response));
        }
Beispiel #10
0
        public void Edit(MessageDTO message)
        {
            ChannelDTO channel = message.Channel;

            ChannelService
            .EditMessage(channel.ChannelId, message);
            Clients.Group(channel.ChannelId).onMessageEdit(message);
        }
Beispiel #11
0
        public ActionResult Create(ChannelDTO channel)
        {
            var model = new EmailViewModel();

            model.Channel = channel;
            Id            = channel.ChannelId;
            return(View(model));
        }
Beispiel #12
0
        public void Send(MessageDTO message)
        {
            ChannelDTO channel = message.Channel;

            message.SendTime = DateTime.UtcNow.ToString("HH:mm:ss");
            ChannelService.AddMessage(channel.ChannelId, message);
            Clients.Group(channel.ChannelId).addMessage(message);
        }
        public async Task <ChannelDTO> GetChannel(long id)
        {
            Channel dbRecord = await _unitOfWork.ChannelRepository.GetById(id);

            ChannelDTO result = _mapper.Map <ChannelDTO>(dbRecord);

            return(result);
        }
Beispiel #14
0
        public void Delete(MessageDTO message)
        {
            ChannelDTO channel = message.Channel;

            ChannelService
            .RemoveMessage(channel.ChannelId, message);
            Clients.Group(channel.ChannelId).onMessageDelete(message);
        }
        private void CheckExistentSegment(ChannelDTO newChannel)
        {
            var segmentosExistentes = _unitOfWork.ChannelRepository.GetAll().Where(t => t.Segmento == newChannel.Segmento).ToList();

            if (segmentosExistentes != null || segmentosExistentes.Count > 0)
            {
                throw new ValidationException("El segmento proporcionado ya existe en base de datos. Ingrese un valor nuevo.");
            }
        }
        private async Task CheckEnterpriseValue(ChannelDTO newChannel)
        {
            Enterprise enterprise = await _unitOfWork.EnterpriseRepository.GetById(newChannel.EnterpriseID);

            if (enterprise == null)
            {
                throw new ValidationException("No existe registro para la empresa proporcionada.");
            }
        }
Beispiel #17
0
 public int addChannel(string accessToken, ChannelDTO ch) {
     User loggedInUser = getValidatedUser(accessToken);
     if (ch.title == null || ch.title == "") {
         throw new InvalidParametersException("channel title not defined or empty");
     }
     Channel channel = new Channel {
         title = ch.title
     };
     return _videoMapper.addChannel(channel);
 }
Beispiel #18
0
        public async Task <ActionResult <ChannelDTO[]> > List()
        {
            //throw new NotImplementedException();
            var user = await GetCurrentUserAsync();

            var userId = user?.Id;

            //user meegeven(filter in repo)
            return(Ok(channelRepository.GetAll(userId).Select(i => ChannelDTO.FromChannel(i))));
        }
Beispiel #19
0
        public void RenameChannel(string id, ChannelDTO channel)
        {
            Channel chl = Database.Channels.Find(
                ch => ch.ChannelId.ToString() == id).First();

            chl.Name = channel.Name;

            Database.Channels.Update(chl);
            Database.Save();
        }
        private void CheckNonBillableProductsValues(ChannelDTO newChannel)
        {
            var matchingNonBillableProductsItems = _unitOfWork.NonBillableProductsRepository.GetAll()
                                                   .Where(t => newChannel.NonBillableProducts.Contains(t.IDNonBillableProducts)).Count();

            if (matchingNonBillableProductsItems != newChannel.NonBillableProducts.Count)
            {
                throw new ValidationException("Uno o más Productos No Facturables proporcionados no corresponde a ningún registro.");
            }
        }
Beispiel #21
0
        public async Task <ActionResult> ExternalLoginConfirmation(ExternalLoginConfirmationViewModel model,
                                                                   string returnUrl)
        {
            /*if (User.Identity.IsAuthenticated)
             * {
             *  return RedirectToAction("Index", "Chat");
             * }*/
            if (ModelState.IsValid)
            {
                // Получение сведений о пользователе от внешнего поставщика входа
                var info = await AuthenticationManager.GetExternalLoginInfoAsync();

                if (info == null)
                {
                    return(View("ExternalLoginFailure"));
                }
                var user = new ApplicationUser
                {
                    UserName = model.Name,
                    LastName = model.LastName,
                    Email    = model.Email
                };
                var result = await UserManager.CreateAsync(user);

                if (result.Succeeded)
                {
                    result = await UserManager.AddLoginAsync(user.Id, info.Login);

                    if (result.Succeeded)
                    {
                        await SignInManager.SignInAsync(user, false, false);

                        var userDTO = new UserDTO
                        {
                            Id       = user.Id,
                            Email    = user.Email,
                            Name     = user.UserName,
                            LastName = user.LastName
                        };
                        if (returnUrl != null)
                        {
                            ChannelDTO channel = new ChannelDTO();
                            channel.Name = returnUrl;
                            return(RedirectToAction("Find", "Chat", channel));
                        }
                        return(RedirectToAction("GetChannels", "Chat", userDTO));
                        // return RedirectToLocal(returnUrl);
                    }
                }
                AddErrors(result);
            }

            ViewBag.ReturnUrl = returnUrl;
            return(View(model));
        }
        private async Task CreateChannelEnterpriseRecord(Channel dbRecord, ChannelDTO channelDTO)
        {
            var newChannelEnterprise = new ChannelEnterprise
            {
                IDChannel    = dbRecord.IDChannel,
                IDEnterprise = channelDTO.EnterpriseID,
                Status       = true
            };

            await _unitOfWork.ChannelEnterpriseRepository.Add(newChannelEnterprise);
        }
Beispiel #23
0
        public async Task <ActionResult <ChannelDTO> > GetById(Guid channelId)
        {
            var channel = channelRepository.GetById(channelId);

            if (channel != null)
            {
                // Generate the user response for given user.
                return(Ok(ChannelDTO.FromChannel(channel)));
            }

            return(NotFound());
        }
        private async Task CheckFinancialSizingValue(ChannelDTO newChannel)
        {
            if (newChannel.FinancialSizingID.HasValue)
            {
                FinancialSizing financialSizing = await _unitOfWork.FinancialSizingRepository.GetById(newChannel.FinancialSizingID.Value);

                if (financialSizing == null)
                {
                    throw new ValidationException("No existe registro para el Dimensionamiento Financiero proporcionado.");
                }
            }
        }
Beispiel #25
0
 public ActionResult Find(ChannelDTO channel)
 {
     if (channelService.IsExistByName(channel.Name))
     {
         return(RedirectToAction("Index", channel));
     }
     else
     {
         TempData.Add("DoesntExistError", true);
         return(RedirectToAction("GetChannels"));
     }
 }
Beispiel #26
0
        public async Task <ActionResult> Login(LoginViewModel model, string returnUrl)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            // Сбои при входе не приводят к блокированию учетной записи
            // Чтобы ошибки при вводе пароля инициировали блокирование учетной записи, замените на shouldLockout: true
            var signedUser = UserManager.FindByEmail(model.Email);

            if (signedUser != null)
            {
                var result =
                    await
                    SignInManager.PasswordSignInAsync(signedUser.UserName, model.Password, model.RememberMe, false);

                switch (result)
                {
                case SignInStatus.Success:
                    var userDTO = new UserDTO
                    {
                        Id       = signedUser.Id,
                        Email    = signedUser.Email,
                        Name     = signedUser.UserName,
                        LastName = signedUser.LastName
                    };
                    if (returnUrl != null)
                    {
                        ChannelDTO channel = new ChannelDTO();
                        channel.Name = returnUrl;
                        return(RedirectToAction("Find", "Chat", channel));
                    }
                    return(RedirectToAction("GetChannels", "Chat", userDTO));

                case SignInStatus.LockedOut:
                    return(View("Lockout"));

                case SignInStatus.RequiresVerification:
                    return(RedirectToAction("SendCode", new { ReturnUrl = returnUrl, model.RememberMe }));

                case SignInStatus.Failure:
                    return(View("ExternalLoginFailure"));

                default:
                    ModelState.AddModelError("", "Неудачная попытка входа.");
                    return(View(model));
                }
            }
            ModelState.AddModelError("", "Неудачная попытка входа.");
            return(View(model));
        }
Beispiel #27
0
        public void AddChannel(ChannelDTO channel)
        {
            var chl = new Channel
            {
                Name = channel.Name
            };

            Database.Channels.Create(chl);
            Database.Save();

            //populate new id back to caller
            channel.ChannelId = chl.ChannelId.ToString();
        }
Beispiel #28
0
        public ChannelDTO GetChannelByName(string name)
        {
            Channel chl = Database.Channels.Find(
                ch => ch.Name == name).First();

            var chlDTO = new ChannelDTO
            {
                ChannelId = chl.ChannelId.ToString(),
                Name      = chl.Name
            };

            return(chlDTO);
        }
        private void enterChannel(ChannelDTO channel)
        {
            exitCurrentView();

            ucChannelView.ChannelDeleted += ucChannelView_ChannelDeleted;
            ucChannelView.ChannelRenamed += ucChannelView_ChannelRenamed;

            txtViewName.Text = channel.Name;
            ucChannelView.SetChannel(channel.Id);

            bViewArea.Child = ucChannelView;

            btnExit.Visibility = Visibility.Visible;
            btnEdit.Visibility = Visibility.Visible;
        }
Beispiel #30
0
        public IEnumerable <ChannelDTO> GetUserChannels(string id)
        {
            List <ChannelDTO> channels = new List <ChannelDTO>();

            foreach (var chl in Database.Users.Find(
                         us => us.Id == id).First().Channels)
            {
                ChannelDTO chlDTO = new ChannelDTO
                {
                    ChannelId = chl.ChannelId.ToString(),
                    Name      = chl.Name
                };
                channels.Add(chlDTO);
            }
            return(channels);
        }