public async Task <IActionResult> Patch(int id)
        {
            try
            {
                var call = await _ctx.Calls.Where(c => c.Id == id).FirstOrDefaultAsync();

                if (call == null)
                {
                    return(BadRequest());
                }

                call.Answered   = true;
                call.AnswerTime = DateTime.UtcNow;

                if (await _ctx.SaveChangesAsync() > 0)
                {
                    // notify
                    return(Ok(new { success = true }));
                }
                else
                {
                    return(BadRequest("Database Error"));
                }
            }
            catch
            {
                return(StatusCode(500));
            }
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("DesignationId,DesignationName,DesignationDetails,IsActive")] Designations designations)
        {
            if (ModelState.IsValid)
            {
                _context.Add(designations);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(designations));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Create([Bind("IndividualId,Nicnumber,PassportNumber,FullName,DateofBirth,GenderId,Address")] Individuals individuals)
        {
            if (ModelState.IsValid)
            {
                _context.Add(individuals);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["GenderId"] = new SelectList(_context.Gender, "GenderId", "Gender1", individuals.GenderId);
            return(View(individuals));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> Create([Bind("StaffId,IndividualId,DesignationId")] Staffs staffs)
        {
            if (ModelState.IsValid)
            {
                _context.Add(staffs);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DesignationId"] = new SelectList(_context.Designations, "DesignationId", "DesignationName", staffs.DesignationId);
            ViewData["IndividualId"]  = new SelectList(_context.Individuals, "IndividualId", "FullName", staffs.IndividualId);
            return(View(staffs));
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> Create([Bind("CallId,CallerIndividualId,CallAttendeeId,CallStateId,Date")] Calls calls)
        {
            if (ModelState.IsValid)
            {
                _context.Add(calls);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CallAttendeeId"]     = new SelectList(_context.Staffs, "StaffId", "StaffId", calls.CallAttendeeId);
            ViewData["CallStateId"]        = new SelectList(_context.States, "StateId", "Details", calls.CallStateId);
            ViewData["CallerIndividualId"] = new SelectList(_context.Individuals, "IndividualId", "Address", calls.CallerIndividualId);
            return(View(calls));
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> Delete(int id)
        {
            try
            {
                var call = await _ctx.Calls.Where(c => c.Id == id).FirstOrDefaultAsync();

                if (call == null)
                {
                    return(BadRequest());
                }

                _ctx.Remove(call);
                if (await _ctx.SaveChangesAsync() > 0)
                {
                    return(Ok(new { success = true }));
                }
                else
                {
                    return(BadRequest("Database Error"));
                }
            }
            catch
            {
                return(StatusCode(500));
            }
        }
Ejemplo n.º 7
0
        public async Task <IActionResult> Index(Call model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    _ctx.Add(model);
                    if (await _ctx.SaveChangesAsync() > 0)
                    {
                        ViewBag.Message = "Problem Reported...";
                        ModelState.Clear();
                    }
                    else
                    {
                        ViewBag.Message = "Failed to save new problem...";
                    }
                }
            }
            catch (Exception)
            {
                ViewBag.Message = "Threw exception trying to save call";
            }

            return(View());
        }
Ejemplo n.º 8
0
        public async Task <bool> SaveUser(string name)
        {
            bool success = false;

            User user = new User {
                Name = name
            };

            try
            {
                await _callCenterContext.Users.AddAsync(user);

                await _callCenterContext.SaveChangesAsync();

                return(success = true);
            }
            catch (Exception ex)
            {
                return(success);

                throw ex;
            }
        }
        public async Task EnsureSeedData()
        {
            if (!_context.Customers.Any())
            {
                var customer1 = new Customer()
                {
                    Name    = "Tan",
                    Surname = "Atagoren",
                    Phone   = "5333762983",
                    Email   = "*****@*****.**",
                };

                var customer2 = new Customer()
                {
                    Name    = "Arda",
                    Surname = "Turan",
                    Phone   = "5333762983",
                    Email   = "*****@*****.**"
                };

                var customer3 = new Customer()
                {
                    Name    = "Veli",
                    Surname = "Kavlak",
                    Phone   = "5333762983",
                    Email   = "*****@*****.**"
                };

                _context.Customers.Add(customer1);
                _context.Customers.Add(customer2);
                _context.Customers.Add(customer3);
            }

            if (!_context.Campaigns.Any())
            {
                var campaign = new Campaign()
                {
                    CreationDate   = DateTime.Now,
                    Description    = "Description 1",
                    ExpirationDate = DateTime.Now.AddDays(60),
                    Name           = "Campaign 1"
                };

                var campaign2 = new Campaign()
                {
                    CreationDate   = DateTime.Now,
                    Description    = "Description 2",
                    ExpirationDate = DateTime.Now.AddDays(90),
                    Name           = "Campaign 2"
                };

                _context.Campaigns.Add(campaign);
                _context.Campaigns.Add(campaign2);
            }
            await _context.SaveChangesAsync();

            if (!_context.Calls.Any())
            {
                var call1 = new Call()
                {
                    CampaignId = 1,
                    CustomerId = 1,
                    Note       = "Call 1 Note",
                    Time       = DateTime.Now,
                };

                var call2 = new Call()
                {
                    CampaignId = 1,
                    CustomerId = 2,
                    Note       = "Call 2 Note",
                    Time       = DateTime.Now,
                };

                var call3 = new Call()
                {
                    CampaignId = 1,
                    CustomerId = 2,
                    Note       = "Call 3 Note",
                    Time       = DateTime.Now,
                };

                _context.Calls.Add(call1);
                _context.Calls.Add(call2);
                _context.Calls.Add(call3);
            }
            await _context.SaveChangesAsync();
        }
Ejemplo n.º 10
0
 public async Task <bool> Commit()
 {
     return((await _context.SaveChangesAsync()) > 0);
 }