public async Task <IActionResult> Edit(int id, [Bind("Id,USERID,EVENTDATETIME")] ApprovedUser approvedUser)
        {
            if (id != approvedUser.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(approvedUser);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ApprovedUserExists(approvedUser.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(approvedUser));
        }
Exemple #2
0
        public ActionResult ShareList(int listId, string searchedEmail)
        {
            string message;

            if (ModelState.IsValid)
            {
                string            userId;
                List <AspNetUser> userList = new List <AspNetUser>();

                foreach (var userRecord in DB.AspNetUsers)
                {
                    if (userRecord.Email == searchedEmail)
                    {
                        userList.Add(userRecord);
                    }
                }

                userId = userList.FirstOrDefault().Id;

                if (userId != null)
                {
                    foreach (var list in DB.UserLists)
                    {
                        if (list.ListId == listId && list.OwnerId == userId)
                        {
                            message = "Lists can not be shared with yourself!";
                            return(RedirectToAction("EditListInfo", new { listId, message }));
                        }
                    }

                    foreach (var appUser in DB.ApprovedUsers)
                    {
                        if (appUser.UserId == userId && appUser.ListId == listId)
                        {
                            message = "That user already has access to this list.";
                            return(RedirectToAction("EditListInfo", new { listId, message }));
                        }
                    }

                    ApprovedUser userEntry = new ApprovedUser();
                    userEntry.UserId = userId;
                    userEntry.ListId = listId;

                    DB.ApprovedUsers.Add(userEntry);
                    DB.SaveChanges();

                    message = "User successfully added.";
                    return(RedirectToAction("EditListInfo", new { listId, message }));
                }
            }
            message = "An error has occured. Please try again.";
            return(RedirectToAction("EditListInfo", new { listId, message }));
        }
Exemple #3
0
        public IActionResult Approve(int?id)
        {
            var employeeUser = _context.EmployeesUsers.Where(i => i.Id == id).FirstOrDefault();
            var employee     = _context.Employees.Where(i => i.Id == employeeUser.EmployeeId).FirstOrDefault();
            var approvedUser = new ApprovedUser()
            {
                Employee      = employeeUser.Employee,
                EmployeeId    = employeeUser.EmployeeId,
                Name          = employeeUser.Name,
                PhoneNumber   = employeeUser.PhoneNumber,
                Surname       = employeeUser.Surname,
                TimeOfArrival = employeeUser.TimeOfArrival,
                Payment       = employeeUser.Payment,
                Transactions  = employeeUser.Transactions
            };

            _context.EmployeesUsers.Remove(employeeUser);
            _context.ApprovedUser.Add(approvedUser);

            _context.SaveChanges();

            return(RedirectToAction("DetailsUser", new { id = employee.Id }));
        }
Exemple #4
0
        public void ApprovedUser()
        {
            var s = new ApprovedUser(182, 1000, 24, true);

            s.Execute();
        }