示例#1
0
        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));
        }
示例#2
0
        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
            });
        }
示例#3
0
        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));
        }
示例#4
0
        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));
        }