public void ShiftPlan_DevelopmentCalls(string managerId, string shiftPlan_DevelopmentCalls)
        {
            PerformanceChart performanceChart = _context.Set <PerformanceChart>().FirstOrDefault(p => p.ManagerId.ToString() == managerId);

            if (performanceChart != null)
            {
                performanceChart.ShiftPlan_DevelopmentCalls = Convert.ToDouble(shiftPlan_DevelopmentCalls.Replace('.', ','));
            }
            else
            {
                _context.Set <PerformanceChart>().Add(new PerformanceChart()
                {
                    Balls_DevelopmentCalls = 0,
                    ManagerId = Convert.ToInt32(managerId),
                    Balls_SubstitutionShifts      = 0,
                    Balls_YourShifts              = 0,
                    NumberPlan_DevelopmentCalls   = 0,
                    NumberPlan_SubstitutionShifts = 0,
                    NumberPlan_YourShifts         = 0,
                    ShiftPlan_DevelopmentCalls    = Convert.ToDouble(shiftPlan_DevelopmentCalls.Replace('.', ',')),
                    ShiftPlan_SubstitutionShifts  = 0,
                    ShiftPlan_YourShifts          = 0
                });
            }
            _context.SaveChanges();
        }
Example #2
0
        public async Task <IActionResult> AddCharts(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var performanceToUpdate = await _context.Performances
                                      .Include(p => p.ConcertProgramme)
                                      .SingleOrDefaultAsync(p => p.ID == id);

            var chartList = new HashSet <int>(performanceToUpdate.ConcertProgramme.Select(c => c.ChartID));


            foreach (var item in cart.ChartsPool)
            {
                if (!chartList.Contains(item.ID))
                {
                    var newPerfChart = new PerformanceChart
                    {
                        PerformanceID = (int)id,
                        ChartID       = item.ID
                    };
                    performanceToUpdate.ConcertProgramme.Add(newPerfChart);
                }
            }
            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(Details), new { id = performanceToUpdate.ID }));
        }
        public IActionResult Get(string managerId)
        {
            PerformanceChart performanceChart = _context.Set <PerformanceChart>().FirstOrDefault(p => p.ManagerId.ToString() == managerId);

            if (performanceChart == null)
            {
                performanceChart = new PerformanceChart()
                {
                    Balls_DevelopmentCalls = 0,
                    ManagerId = Convert.ToInt32(managerId),
                    Balls_SubstitutionShifts      = 0,
                    Balls_YourShifts              = 0,
                    NumberPlan_DevelopmentCalls   = 0,
                    NumberPlan_SubstitutionShifts = 0,
                    NumberPlan_YourShifts         = 0,
                    ShiftPlan_DevelopmentCalls    = 0,
                    ShiftPlan_SubstitutionShifts  = 0,
                    ShiftPlan_YourShifts          = 0
                };
            }
            return(Ok(performanceChart));
        }
Example #4
0
        public async Task <IActionResult> EditArtistsListPost(int id, int performanceId)
        {
            //_context.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;

            var personInstrumentsToUpdate = await _context.PerformanceCharts
                                            .Where(p => p.PerformanceID == performanceId)
                                            .Where(p => p.ChartID == id)
                                            .AsNoTracking()
                                            .ToListAsync();

            var chartToUpdate = await _context.Charts
                                .Include(c => c.Instrumentation)
                                .ThenInclude(i => i.Instrument)
                                .AsNoTracking()
                                .SingleOrDefaultAsync(c => c.ID == id);

            var personInstruments = chartToUpdate.Instrumentation.Select(i => i.Instrument)
                                    .OrderBy(i => i.ScoreOrder);

            if (personInstrumentsToUpdate.Count() == 1 && personInstrumentsToUpdate[0].Instrument == null)
            {
                foreach (var instrument in personInstruments)
                {
                    if (personInstrumentsToUpdate[0].InstrumentID == null)
                    {
                        personInstrumentsToUpdate[0].InstrumentID = instrument.ID;
                        personInstrumentsToUpdate[0].PersonID     =
                            int.Parse(Request.Form[$"PersonID_{instrument.ID}"]);
                        _context.Entry <PerformanceChart>(personInstrumentsToUpdate[0])
                        .State = EntityState.Modified;
                    }
                    else
                    {
                        var perInst = new PerformanceChart
                        {
                            PerformanceID  = performanceId,
                            ChartID        = id,
                            InstrumentID   = instrument.ID,
                            PersonID       = int.Parse(Request.Form[$"PersonID_{instrument.ID}"]),
                            ChartListOrder = personInstrumentsToUpdate[0].ChartListOrder
                        };
                        _context.Entry <PerformanceChart>(perInst).State = EntityState.Added;
                        personInstrumentsToUpdate.Add(perInst);
                    }
                }
            }
            else
            {
                foreach (var instrument in personInstruments)
                {
                    foreach (var item in personInstrumentsToUpdate)
                    {
                        if (instrument.ID == item.InstrumentID)
                        {
                            item.PersonID = int.Parse(Request.Form[$"PersonID_{instrument.ID}"]);
                            _context.Entry <PerformanceChart>(item)
                            .State = EntityState.Modified;
                        }
                    }
                }
            }
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                Console.WriteLine(new Exception(ex.Message.ToString(), ex.InnerException));

                var instrumentPersonInfo = new InstrumentPersonInfo
                {
                    Chart             = chartToUpdate,
                    PersonInstruments = personInstruments,
                    PerformanceID     = performanceId
                };

                var pers = from p in _context.People
                           orderby p.LastName
                           select p;

                ViewData["Artists"] = new SelectList(pers.AsNoTracking(), "ID", "FullName");
                return(View(instrumentPersonInfo));
            }
            return(RedirectToAction(nameof(ShowArtistsList),
                                    new { id = id, performanceId = performanceId }));
        }