public PerformerInEntertainment(Performer performer, Entertainment entertainment, PerformerInEntertainment.Role performerRole) : base()
        {
            PerformerId     = performer.Id;
            EntertainmentId = entertainment.Id;
            PerformerRole   = performerRole;

            Logger.Info("PerformerInEntertainment.PerformerInEntertainment", "Створено екземпляр PerformerInEntertainment.");
        }
        private string GetPerformersStringByRole(PerformerInEntertainment.Role role)
        {
            Performer[] performers = Performer.GetPerformerByEntertainmentAndRole(_entertainment.EntertainmentDL, role);
            if (performers == null)
            {
                return(null);
            }

            string result = "";

            foreach (var performer in performers)
            {
                PerformerVM performerVM = new PerformerVM(performer);
                result += performerVM.ToString();
                result += ", ";
            }
            return(result.Remove(result.Length - 2, 2));
        }
Example #3
0
        public PerformerMiniViewModel(PerformerVM performer, PerformerInEntertainment.Role role)
        {
            _performer = performer;

            Role = role;

            Entertainment[] entertainmentByPerformer = Entertainment.GetEntertainmentByPerformer(performer.PerformerDL);
            if (entertainmentByPerformer != null)
            {
                AvaragePerformerPoint = Entertainment.AverageCriticPointForEntertainments(entertainmentByPerformer);
            }

            if (role == PerformerInEntertainment.Role.MovieCast)
            {
                Entertainment[] lastThreeActorsEntertainments = Entertainment.GetLastThreeEntertainmentByActor(performer.PerformerDL);
                if (lastThreeActorsEntertainments != null)
                {
                    List <EntertainmentVM> result = new List <EntertainmentVM>();
                    foreach (var entertainment in lastThreeActorsEntertainments)
                    {
                        result.Add(new EntertainmentVM(entertainment));
                    }
                    LastThreePerformersEntertainments = result.ToArray();
                }
            }
            if (role == PerformerInEntertainment.Role.AlbumSinger)
            {
                Entertainment[] lastThreeActorsEntertainments = Entertainment.GetLastThreeEntertainmentBySinger(performer.PerformerDL);
                if (lastThreeActorsEntertainments != null)
                {
                    List <EntertainmentVM> result = new List <EntertainmentVM>();
                    foreach (var entertainment in lastThreeActorsEntertainments)
                    {
                        result.Add(new EntertainmentVM(entertainment));
                    }
                    LastThreePerformersEntertainments = result.ToArray();
                }
            }
        }
Example #4
0
        public EditOrAddPerformerInEntertainmentUserControlVM(EntertainmentVM entertainment, PerformerInEntertainment.Role role)
        {
            _entertainment = entertainment;
            _role          = role;

            Performer.Type type;
            switch (role)
            {
            case PerformerInEntertainment.Role.AlbumBand:
                type = Performer.Type.Band;
                break;

            case PerformerInEntertainment.Role.AlbumRecordLabel:
                type = Performer.Type.RecordLabel;
                break;

            case PerformerInEntertainment.Role.AlbumSinger:
                type = Performer.Type.Person;
                break;

            case PerformerInEntertainment.Role.GameCast:
                type = Performer.Type.Person;
                break;

            case PerformerInEntertainment.Role.GameDeveloperCompany:
                type = Performer.Type.GameDeveloperCompany;
                break;

            case PerformerInEntertainment.Role.GamePlatform:
                type = Performer.Type.GamePlatform;
                break;

            case PerformerInEntertainment.Role.MovieCast:
                type = Performer.Type.Person;
                break;

            case PerformerInEntertainment.Role.MovieDirector:
                type = Performer.Type.Person;
                break;

            case PerformerInEntertainment.Role.MoviePlotWriter:
                type = Performer.Type.Person;
                break;

            case PerformerInEntertainment.Role.MoviePrincipalCast:
                type = Performer.Type.Person;
                break;

            case PerformerInEntertainment.Role.MovieProducer:
                type = Performer.Type.Person;
                break;

            case PerformerInEntertainment.Role.MovieProduction:
                type = Performer.Type.MovieProduction;
                break;

            case PerformerInEntertainment.Role.TVCast:
                type = Performer.Type.Person;
                break;

            case PerformerInEntertainment.Role.TVNetwork:
                type = Performer.Type.TVNetwork;
                break;

            default:
                type = Performer.Type.Person;
                break;
            }

            _performerViewModel = new PerformerUserControlVM(type);

            _performerViewModel.PerformerTypesComboBoxVisibility = Visibility.Collapsed;
            _performerViewModel.AddButtonVisibility    = Visibility.Collapsed;
            _performerViewModel.EditButtonVisibility   = Visibility.Collapsed;
            _performerViewModel.DeleteButtonVisibility = Visibility.Collapsed;

            PerformerInEntertainment[] performerInEntertainments = PerformerInEntertainment.GetPerformerInEntertainmentByEntertainmentAndRole(_entertainment.EntertainmentDL, role);

            if (performerInEntertainments != null)
            {
                List <Guid> performerIds = new List <Guid>();

                foreach (var performerInEntertainment in performerInEntertainments)
                {
                    _performerInEntertainmentCollection.Add(new PerformerInEntertainmentVM(performerInEntertainment));
                    performerIds.Add(performerInEntertainment.PerformerId);
                }

                Performer[] performers = Performer.GetByIds(performerIds.ToArray());
                foreach (var performer in performers)
                {
                    _addedPerformerCollection.Add(new PerformerVM(performer));
                }
            }

            Logger.Info("EditOrAddPerformerInEntertainmentUserControlVM.EditOrAddPerformerInEntertainmentUserControlVM", "Екземпляр EditOrAddPerformerInEntertainmentUserControlVM створений.");
        }
 public PerformerInEntertainmentVM(PerformerVM performer, EntertainmentVM entertainment, PerformerInEntertainment.Role performerRole)
 {
     _performerInEntertainment = new PerformerInEntertainment(performer.PerformerDL, entertainment.EntertainmentDL, performerRole);
 }
Example #6
0
        public static PerformerInEntertainment[] GetPerformerInEntertainmentByEntertainmentAndRole(Entertainment entertainment, PerformerInEntertainment.Role role)
        {
            lock (_locker)
            {
                List <PerformerInEntertainment> result = new List <PerformerInEntertainment>();

                _dataAdapter.SelectCommand.CommandText = "SELECT * FROM " + _tableName + " WHERE EntertainmentId=@id AND PerformerRole=@role";

                if (!_dataAdapter.SelectCommand.Parameters.Contains("@id"))
                {
                    _dataAdapter.SelectCommand.Parameters.Add(new SqlParameter("@id", entertainment.Id));
                }
                else
                {
                    _dataAdapter.SelectCommand.Parameters["@id"].Value = entertainment.Id;
                }
                if (!_dataAdapter.SelectCommand.Parameters.Contains("@role"))
                {
                    _dataAdapter.SelectCommand.Parameters.Add(new SqlParameter("@role", role.ToString()));
                }
                else
                {
                    _dataAdapter.SelectCommand.Parameters["@role"].Value = role.ToString();
                }

                _dataAdapter.Fill(_dataTable);
                var selectedRows = from row in _dataTable.AsEnumerable().AsParallel()
                                   where ((Guid)row["EntertainmentId"] == entertainment.Id) &&
                                   ((PerformerInEntertainment.Role)Enum.Parse(typeof(PerformerInEntertainment.Role), row["PerformerRole"].ToString()) == role)
                                   select row;
                foreach (DataRow dr in selectedRows)
                {
                    result.Add(new PerformerInEntertainment(dr));
                }
                if (result.Count != 0)
                {
                    return(result.ToArray());
                }
                return(null);
            }
        }
Example #7
0
 public PerformerInEntertainment(Performer performer, Entertainment entertainment, PerformerInEntertainment.Role performerRole) : base()
 {
     PerformerId     = performer.Id;
     EntertainmentId = entertainment.Id;
     PerformerRole   = performerRole;
 }
Example #8
0
        public static Performer[] GetPerformerByEntertainmentAndRole(Entertainment entertainment, PerformerInEntertainment.Role role)
        {
            PerformerInEntertainment[] performerInEntertainments = PerformerInEntertainment.GetPerformerInEntertainmentByEntertainmentAndRole(entertainment, role);
            if (performerInEntertainments == null)
            {
                return(null);
            }
            List <Guid> ids = new List <Guid>();

            foreach (var performerInEntertainment in performerInEntertainments)
            {
                ids.Add(performerInEntertainment.PerformerId);
            }
            return(Performer.GetByIds(ids.ToArray()));
        }
        private PerformerVM[] GetPerformerVMByEntertainmentVMAndRole(EntertainmentVM entertainment, PerformerInEntertainment.Role role)
        {
            Performer[] performers = Performer.GetPerformerByEntertainmentAndRole(entertainment.EntertainmentDL, role);
            if (performers == null)
            {
                return(null);
            }

            List <PerformerVM> result = new List <PerformerVM>();

            foreach (var performer in performers)
            {
                result.Add(new PerformerVM(performer));
            }
            return(result.ToArray());
        }
        public PerformerInEntertainmentVM(PerformerVM performer, EntertainmentVM entertainment, PerformerInEntertainment.Role performerRole)
        {
            _performerInEntertainment = new PerformerInEntertainment(performer.PerformerDL, entertainment.EntertainmentDL, performerRole);

            Logger.Info("PerformerInEntertainmentVM.PerformerInEntertainmentVM", "Екземпляр PerformerInEntertainmentVM створений.");
        }