Ejemplo n.º 1
0
        public override async Task <ActionResult <Employee> > Delete(Guid id)
        {
            var employee = await _repository.Delete(id);

            if (employee == null)
            {
                return(NotFound());
            }

            var client = await _clientsRepository.GetClient(employee.PersonId);

            if (client == null)
            {
                await _peopleRepository.Delete(employee.PersonId);
            }

            return(employee);
        }
Ejemplo n.º 2
0
        public ActionResult EditClient(FormCollection formValues, int clientID)
        {
            if (formValues["Submit"].Equals("Zapisz", StringComparison.InvariantCultureIgnoreCase))
            {
                ClientsRepository clientRepo = new ClientsRepository();
                Client            client     = clientRepo.GetClient(clientID);
                UpdateModel <Client>(client);
                if (ValidateClient(client.ClientName, client.ClientPrefix))
                {
                    clientRepo.SubmitChanges();
                }
                else
                {
                    return(View(client));
                }
            }

            return(RedirectToAction("Clients"));
        }
Ejemplo n.º 3
0
        public List <MembershipUser> GetClientUsers(int clientID)
        {
            ClientsRepository clientsRepository = new ClientsRepository();
            var client = clientsRepository.GetClient(clientID);

            //all users from current client
            List <MembershipUser> allUsers;

            if (!string.IsNullOrEmpty(client.ClientPrefix))
            {
                allUsers = GetAllUsers()
                           .Where(u => client.UsersInClients.Where(uc => uc.UserID == (Guid)u.ProviderUserKey).Count() > 0 &&
                                  u.UserName.StartsWith(client.ClientPrefix)).ToList();
            }
            else
            {
                allUsers = GetAllUsers();
                //.Where(u => client.UsersInClients.Where(uc => uc.UserID == (Guid)u.ProviderUserKey).Count() > 0).ToList();
            }

            return(allUsers);
        }