Exemplo n.º 1
0
        public List <Balance> GetByRange(int skip, int take, EStatusVideo statusVideo, int id, string word)
        {
            List <VideoEquipment> videoEquipment = _repository.GetByRange(skip, take, id);
            List <Balance>        listBalance    = new List <Balance>();
            Balance balance = new Balance();


            DateTime date           = DateTime.Today;
            DateTime ultimoDiaDoMes = new DateTime(date.Year, date.Month, DateTime.DaysInMonth(date.Year, date.Month));
            decimal  valueMonth     = 0;

            //saber a quantidade de dias do mes atual
            int amoutDaysOfMonth = DateTime.DaysInMonth(date.Year, date.Month);

            //dividir o valor mensal pela quantidade de dias do mes

            //Se a data de inicio do video for mes atual, calcular a diferença até o ultimo dia do mes
            //Se a data de fim do video for no mes atual, calcular a diferenca até a da de fim
            //multiplicar a quantidade de dias do mes pelo valor diario ganho em cima do video



            foreach (var video in videoEquipment)
            {
                int amountDaysVideoVigente = amoutDaysOfMonth;

                // video.Video.Plan

                decimal value = (video.Video.Plan.ValueEquipmentMain + video.Video.Plan.ValueEquipmentAdditional * video.Video.TvAdditional) / amoutDaysOfMonth;


                if (video.Video.DateStart.Month == DateTime.Today.Month && video.Video.DateEnd.Month != DateTime.Today.Month && video.Video.Status == statusVideo)
                {
                    amountDaysVideoVigente = amoutDaysOfMonth - video.Video.DateStart.Day + 1;
                    //listBalance.Add(new Balance(video.IdVideo, video.Video.Company.FantasyName, value * amountDaysVideoVigente, _repository.GetVideoCountByEquipment(video.IdVideo), amountDaysVideoVigente, value, video.Video.DateStart, video.Video.DateEnd));
                }
                else if (video.Video.DateEnd.Month == DateTime.Today.Month && video.Video.DateStart.Month != DateTime.Today.Month && video.Video.Status == statusVideo)
                {
                    amountDaysVideoVigente = amoutDaysOfMonth - video.Video.DateEnd.Day + 1;
                    //listBalance.Add(new Balance(video.IdVideo, video.Video.Company.FantasyName, value * amountDaysVideoVigente, _repository.GetVideoCountByEquipment(video.IdVideo), amountDaysVideoVigente, value, video.Video.DateStart, video.Video.DateEnd));
                }
                else if (video.Video.DateEnd.Month == DateTime.Today.Month && video.Video.DateStart.Month == DateTime.Today.Month && video.Video.Status == statusVideo)
                {
                    amountDaysVideoVigente = video.Video.DateEnd.Day - video.Video.DateStart.Day + 1;
                    //listBalance.Add(new Balance(video.IdVideo, video.Video.Company.FantasyName, value * amountDaysVideoVigente, _repository.GetVideoCountByEquipment(video.IdVideo), amountDaysVideoVigente, value, video.Video.DateStart, video.Video.DateEnd));
                }

                if ((video.Video.DateEnd.Month == DateTime.Today.Month || video.Video.DateStart.Month == DateTime.Today.Month || video.Video.DateStart.Month <= DateTime.Today.Month && video.Video.DateEnd.Month >= DateTime.Today.Month) && video.Video.Status == statusVideo)
                {
                    listBalance.Add(new Balance(video.IdVideo, video.Video.Company.FantasyName, value * amountDaysVideoVigente, video.Video.TvAdditional + 1, amountDaysVideoVigente, value, video.Video.DateStart, video.Video.DateEnd, video.Video.Plan.Title));
                }
            }

            //balance.AjustBalance(statusVideo,videoEquipment);

            return(balance.SerializableList(listBalance));
        }
 public List <VideoEquipment> GetByRange(int skip, int take, string word)
 {
     return(_repository.GetByRange(skip, take, word));
 }