public ICollection <Common.DataMembers.Output.Usuario> Sorteo(int lote) { var ganadores = new List <Common.DataMembers.Output.Usuario>(); var articulos = _articuloInfrastructure.GetByLote(lote); articulos.ToList().ForEach(x => { var users = _usuarioInfrastructure.GetByArticulo(x.Id); if (!users.Any()) { return; } var ganador = new Random().Next(1, users.Count); var usr = users.Skip(ganador - 1).Take(1).FirstOrDefault(); ganadores.Add(usr); _articuloInfrastructure.AdjudicarArticulo(x.Id, usr.Id); _notificacionesInfrastructure.Create(new Common.DataMembers.Input.Notificacion { IdArticulo = x.Id, IdUsuario = usr.Id }); }); _loteInfrastructure.ChangeStatus(lote, Ecommerce.Common.Constant.Properties.Estado.Cerrado); return(ganadores); }
public ICollection <Common.DataMembers.Output.Articulo> GetLote(int lote) { return(_articuloInfrastructure.GetByLote(lote)); }