public async Task <IActionResult> Edit(string id, [Bind("CallingPlanId,Minutes,Messages")] CallingPlan callingPlan) { //if (id != callingPlan.CallingPlanId) //{ // return NotFound(); //} if (ModelState.IsValid) { var cp = await _context.CallingPlans.FindAsync(id); try { //_context.Update(costCenter); _context.CallingPlans.Remove(cp); _context.Add(callingPlan); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CallingPlanExists(callingPlan.CallingPlanId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index), new { cPCheck = "On", minutesCheck = "On", costCheck = "On" })); } return(View(callingPlan)); }
private void StoreCallingPlanAssigment(PhoneNumber phoneNumber, DateTime date) { if (phoneNumber.Plan == null) { return; } var plan = _dbContext.CallingPlans.Find(phoneNumber.Plan); if (plan == null) { plan = new CallingPlan() { CallingPlanId = phoneNumber.Plan }; _dbContext.CallingPlans.Add(plan); } _dbContext.CallingPlanAssignments.Add(new CallingPlanAssignment() { CallingPlanId = plan.CallingPlanId, PhoneNumber = phoneNumber.Number, Month = date.Month, Year = date.Year }); }
public async Task <IActionResult> Edit(int id, [Bind("CallingPlanId,Minutes,Messages")] CallingPlan callingPlan) { if (id != callingPlan.CallingPlanId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(callingPlan); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CallingPlanExists(callingPlan.CallingPlanId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(callingPlan)); }
public async Task <IActionResult> Create([Bind("CallingPlanId,Minutes,Messages")] CallingPlan callingPlan) { if (ModelState.IsValid) { _context.Add(callingPlan); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index), new { cPCheck = "On", minutesCheck = "On", costCheck = "On" })); } return(View(callingPlan)); }