public async Task <IActionResult> Edit([Bind("PhoneNumber,CallingPlanAssignmentDateTime,CallingPlanId,MinutesConsumed,MessagesSent")] MobilePhoneCallingPlanAssignment mobilePhoneCallingPlanAssignment)
        {
            if (MobilePhoneCallingPlanAssignmentExists(mobilePhoneCallingPlanAssignment))
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(mobilePhoneCallingPlanAssignment);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MobilePhoneCallingPlanAssignmentExists(mobilePhoneCallingPlanAssignment))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CallingPlanId"] = new SelectList(_context.CallingPlans, "CallingPlanId", "CallingPlanId", mobilePhoneCallingPlanAssignment.CallingPlanId);
            ViewData["PhoneNumber"]   = new SelectList(_context.PhoneLines, "PhoneNumber", "PhoneNumber", mobilePhoneCallingPlanAssignment.PhoneNumber);
            return(View(mobilePhoneCallingPlanAssignment));
        }
 private bool MobilePhoneCallingPlanAssignmentExists(MobilePhoneCallingPlanAssignment m)
 {
     return(_context.MobilePhoneCallingPlanAssignments.Any(e => e.PhoneNumber == m.PhoneNumber &&
                                                           e.MessagesSent == m.MessagesSent &&
                                                           e.MinutesConsumed == m.MinutesConsumed &&
                                                           e.CallingPlanId == m.CallingPlanId &&
                                                           e.CallingPlanAssignmentDateTime == m.CallingPlanAssignmentDateTime));
 }
        public async Task <IActionResult> DeleteConfirmed([Bind("PhoneNumber,CallingPlanAssignmentDateTime,CallingPlanId,MinutesConsumed,MessagesSent")] MobilePhoneCallingPlanAssignment mobilePhoneCallingPlanAssignment)
        {
            var _mobilePhoneCallingPlanAssignment = await _context.MobilePhoneCallingPlanAssignments.FindAsync(mobilePhoneCallingPlanAssignment.PhoneNumber, mobilePhoneCallingPlanAssignment.CallingPlanAssignmentDateTime, mobilePhoneCallingPlanAssignment.CallingPlanId);

            _context.MobilePhoneCallingPlanAssignments.Remove(_mobilePhoneCallingPlanAssignment);
            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
        public async Task <IActionResult> Create([Bind("PhoneNumber,CallingPlanAssignmentDateTime,CallingPlanId,MinutesConsumed,MessagesSent")] MobilePhoneCallingPlanAssignment mobilePhoneCallingPlanAssignment)
        {
            if (ModelState.IsValid)
            {
                _context.Add(mobilePhoneCallingPlanAssignment);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CallingPlanId"] = new SelectList(_context.CallingPlans, "CallingPlanId", "CallingPlanId", mobilePhoneCallingPlanAssignment.CallingPlanId);
            ViewData["PhoneNumber"]   = new SelectList(_context.PhoneLines, "PhoneNumber", "PhoneNumber", mobilePhoneCallingPlanAssignment.PhoneNumber);
            return(View(mobilePhoneCallingPlanAssignment));
        }