public async Task <IActionResult> Edit([Bind("Extension,LandlinePhoneCallDateTime,EmployeeId,Destination,LandlinePhoneCallDuration,LandlinePhoneCallAddressee")] LandlinePhoneCall landlinePhoneCall)
        {
            if (LandlinePhoneCallExists(landlinePhoneCall))
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(landlinePhoneCall);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!LandlinePhoneCallExists(landlinePhoneCall))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EmployeeId"] = new SelectList(_context.Employees, "EmployeeId", "EmployeeId", landlinePhoneCall.EmployeeId);
            return(View(landlinePhoneCall));
        }
        public async Task <IActionResult> DeleteConfirmed([Bind("Extension,LandlinePhoneCallDateTime,EmployeeId,Destination,LandlinePhoneCallDuration,LandlinePhoneCallAddressee")] LandlinePhoneCall landlinePhoneCall)
        {
            var _landlinePhoneCall = await _context.LandLinePhoneCalls.FindAsync(landlinePhoneCall.Extension, landlinePhoneCall.LandlinePhoneCallDateTime, landlinePhoneCall.EmployeeId);

            _context.LandLinePhoneCalls.Remove(_landlinePhoneCall);
            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
 private bool LandlinePhoneCallExists(LandlinePhoneCall l)
 {
     return(_context.LandLinePhoneCalls.Any(e => e.Extension == l.Extension &&
                                            e.Destination == l.Destination &&
                                            l.Employee == e.Employee &&
                                            l.LandlinePhoneCallAddressee == e.LandlinePhoneCallAddressee &&
                                            l.LandlinePhoneCallCost == e.LandlinePhoneCallCost &&
                                            l.LandlinePhoneCallDuration == e.LandlinePhoneCallDuration &&
                                            l.LandlinePhoneCallDateTime == e.LandlinePhoneCallDateTime));
 }
Ejemplo n.º 4
0
 private bool LandlinePhoneCallExists(LandlinePhoneCall l)
 {
     return(_context.LandLinePhoneCalls.Any(e => e.Extension == l.Extension &&
                                            e.Destination == l.Destination &&
                                            l.Employee == e.Employee &&
                                            l.Addressee == e.Addressee &&
                                            Math.Abs(l.Cost - e.Cost) < 0.01 &&
                                            Math.Abs(l.Duration - e.Duration) < 0.01 &&
                                            l.DateTime == e.DateTime));
 }
        public async Task <IActionResult> Create([Bind("Extension,LandlinePhoneCallDateTime,EmployeeId,Destination,LandlinePhoneCallDuration,LandlinePhoneCallAddressee,LandlinePhoneCallCost")] LandlinePhoneCall landlinePhoneCall)
        {
            if (ModelState.IsValid)
            {
                _context.Add(landlinePhoneCall);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EmployeeId"] = new SelectList(_context.Employees, "EmployeeId", "EmployeeId", landlinePhoneCall.EmployeeId);
            return(View(landlinePhoneCall));
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> Edit([Bind("Extension,LandlinePhoneCallDateTime,EmployeeId,Destination,LandlinePhoneCallDuration,LandlinePhoneCallAddressee")] LandlinePhoneCall landlinePhoneCall)
        {
            var landlinePhoneCallFromDb = await _context.LandLinePhoneCalls
                                          .Include(l => l.Employee)
                                          .FirstOrDefaultAsync(m => m.Extension == landlinePhoneCall.Extension && m.DateTime == landlinePhoneCall.DateTime && m.EmployeeId == landlinePhoneCall.EmployeeId);

            landlinePhoneCallFromDb.Destination = landlinePhoneCall.Destination;
            landlinePhoneCallFromDb.Duration    = landlinePhoneCall.Duration;
            landlinePhoneCallFromDb.Addressee   = landlinePhoneCall.Addressee;
            if (ModelState.IsValid)
            {
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EmployeeId"] = new SelectList(_context.Employees, "EmployeeId", "EmployeeId", landlinePhoneCall.EmployeeId);
            return(View(landlinePhoneCall));
        }