示例#1
0
        public async Task <IActionResult> DeleteConfirmed([Bind("PhoneNumber,Month,Year,CallingPlanId")] CallingPlanAssignment CallingPlanAssignment)
        {
            var _CallingPlanAssignment = await _context.CallingPlanAssignments
                                         .Include(m => m.CallingPlan)
                                         .Include(m => m.PhoneLine)
                                         .FirstOrDefaultAsync(m => m.PhoneNumber == CallingPlanAssignment.PhoneNumber && m.Month == CallingPlanAssignment.Month && m.Year == CallingPlanAssignment.Year && m.CallingPlanId == CallingPlanAssignment.CallingPlanId);

            //var _CallingPlanAssignment = await _context.CallingPlanAssignments.FindAsync(CallingPlanAssignment.PhoneNumber,CallingPlanAssignment.Month, CallingPlanAssignment.Year, CallingPlanAssignment.CallingPlanId);
            _context.CallingPlanAssignments.Remove(_CallingPlanAssignment);
            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(Index), new { phoneNumberCheck = "On", cPCheck = "On", monthCheck = "On", yearCheck = "On" }));
        }
示例#2
0
        public async Task <IActionResult> Create([Bind("PhoneNumber,Month,Year,CallingPlanId")] CallingPlanAssignment callingPlanAssignment)
        {
            if (ModelState.IsValid)
            {
                _context.Add(callingPlanAssignment);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index), new { phoneNumberCheck = "On", cPCheck = "On", monthCheck = "On", yearCheck = "On" }));
            }
            ViewData["CallingPlanId"] = new SelectList(_context.CallingPlans, "CallingPlanId", "CallingPlanId", callingPlanAssignment.CallingPlanId);
            ViewData["PhoneNumber"]   = new SelectList(_context.PhoneLines, "PhoneNumber", "PhoneNumber", callingPlanAssignment.PhoneNumber);
            List <MonthSelect> months = new List <MonthSelect>()
            {
                new MonthSelect("enero", 1), new MonthSelect("febrero", 2), new MonthSelect("marzo", 3),
                new MonthSelect("abril", 4), new MonthSelect("mayo", 5), new MonthSelect("junio", 6), new MonthSelect("julio", 7), new MonthSelect("agosto", 8),
                new MonthSelect("septiembre", 9), new MonthSelect("octubre", 10), new MonthSelect("noviembre", 11), new MonthSelect("diciembre", 12)
            };

            ViewData["Month"] = new SelectList(months, "MonthNumber", "Name");
            return(View(callingPlanAssignment));
        }
示例#3
0
 private bool CallingPlanAssignmentExists(CallingPlanAssignment m)
 {
     return(_context.CallingPlanAssignments.Any(e => e.PhoneNumber == m.PhoneNumber &&
                                                e.CallingPlanId == e.CallingPlanId && e.Month == m.Month && m.Year == m.Year));
 }
示例#4
0
        public async Task <IActionResult> Edit([Bind("PhoneNumber,Month,Year,CallingPlanId")] CallingPlanAssignment callingPlanAssignment)
        {
            //
            Tuple <bool, string>[] show = new Tuple <bool, string> [4];
            var check1 = true;
            var check2 = true;
            var check3 = true;
            var check4 = true;


            show[0] = new Tuple <bool, string>(check1, null);
            show[1] = new Tuple <bool, string>(check2, null);
            show[2] = new Tuple <bool, string>(check3, null);
            show[3] = new Tuple <bool, string>(check4, null);
            //
            if (ModelState.IsValid)
            {
                _context.Add(callingPlanAssignment);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index), new { phoneNumberCheck = "On", cPCheck = "On", monthCheck = "On", yearCheck = "On" }));
            }
            ViewData["top"]     = 20;
            ViewData["mult"]    = 0;
            ViewData["columns"] = show;
            ViewData["page"]    = 0;
            if (CallingPlanAssignmentExists(callingPlanAssignment))
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(callingPlanAssignment);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CallingPlanAssignmentExists(callingPlanAssignment))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index), new { phoneNumberCheck = "On", cPCheck = "On", monthCheck = "On", yearCheck = "On" }));
            }
            ViewData["CallingPlanId"] = new SelectList(_context.CallingPlans, "CallingPlanId", "CallingPlanId", callingPlanAssignment.CallingPlanId);
            ViewData["PhoneNumber"]   = new SelectList(_context.PhoneLines, "PhoneNumber", "PhoneNumber", callingPlanAssignment.PhoneNumber);
            List <MonthSelect> months = new List <MonthSelect>()
            {
                new MonthSelect("enero", 1), new MonthSelect("febrero", 2), new MonthSelect("marzo", 3),
                new MonthSelect("abril", 4), new MonthSelect("mayo", 5), new MonthSelect("junio", 6), new MonthSelect("julio", 7), new MonthSelect("agosto", 8),
                new MonthSelect("septiembre", 9), new MonthSelect("octubre", 10), new MonthSelect("noviembre", 11), new MonthSelect("diciembre", 12)
            };

            ViewData["Month"] = new SelectList(months, "MonthNumber", "Name");
            return(View(callingPlanAssignment));
        }