示例#1
0
        public async Task <IActionResult> ClientInfo() // returns current personal information of user for user
        {
            UserIdentity user = new UserIdentity();
            string       name = HttpContext.User.Identity.Name;

            user = await userManager.FindByNameAsync(name);

            Client client = new Models.Client();

            client = clientRepo.GetClientByEmail(user.Email);
            return(View(client));
        }
示例#2
0
        public void GetGetClientByEmail()
        {
            //Arrange
            Client client = new Client();
            string email  = "*****@*****.**";

            //Act
            client = clientRepo.GetClientByEmail(email);
            //Assert
            Assert.Equal("Homes", client.LastName);
        }
示例#3
0
        public IActionResult CreateProject(int bidID)
        {
            VMCreateProject projectVM = new VMCreateProject();                     //creates vm to pass to view
            Bid             b         = bidrepo.GetBidByID(bidID);                 //gets appropriate bid from database
            Client          c         = clientRepo.GetClientByEmail(b.User.Email); //looks for client from database

            if (c == null)                                                         //if client not found
            {
                //create client
                Client altC = new Client();
                altC.Email        = b.User.Email;
                altC.FirstName    = b.User.FirstName;
                altC.LastName     = b.User.LastName;
                altC.PhoneNumber  = b.User.PhoneNumber;
                altC.UserIdentity = b.User;
                clientRepo.Create(altC);

                //finds created client, now in database
                Client createdClient = clientRepo.GetClientByEmail(altC.Email);

                b.User.ClientCreated = true; //confirms client now exists

                //adds bid and client info to project object
                projectVM.BidID    = bidID;
                projectVM.LastName = b.User.LastName;
                projectVM.ClientID = createdClient.ClientID;
                projectVM.Email    = b.User.Email;
            }
            else //if client is found
            {
                //adds client and bid to project
                projectVM.BidID    = bidID;
                projectVM.ClientID = c.ClientID;
                projectVM.LastName = b.User.LastName;
                projectVM.Email    = b.User.Email;
            }

            return(View(projectVM));
        }
        public async Task <IActionResult> InvoiceList(int id) // Displays all invoices for user on UserPage
        {
            UserIdentity user = new UserIdentity();
            string       name = HttpContext.User.Identity.Name;

            user = await userManager.FindByNameAsync(name);

            Client client = new Client();

            client = clientRepo.GetClientByEmail(user.Email);
            List <Invoice> invoices = new List <Invoice>();

            invoices = invoiceRepo.GetAllInvoicesByClient(client);
            if (invoices == null)
            {
                TempData["ErrorMessage"] = "No Invoices";
                return(RedirectToAction("UserPage", "User"));
            }
            else
            {
                return(View(invoices));
            }
        }
示例#5
0
        public IViewComponentResult Invoke(string email)
        {
            UserIdentity user = userRepo.GetUser(email);

            Client c = repository.GetClientByEmail(email);

            if (c != null)
            {
                Client client = new Client();
                client = repository.GetClientByEmail(email);
                return(View(client));
            }
            else
            {
                c = new Client
                {
                    FirstName = user.FirstName,
                    LastName  = user.LastName,
                    Email     = user.Email
                };

                return(View(c));
            }
        }
示例#6
0
        public IViewComponentResult Invoke(string email)
        {
            List <Project> projects = new List <Project>();
            Client         client   = new Models.Client();

            client = clientRepo.GetClientByEmail(email);
            if (client == null)
            {
                return(View(projects));
            }
            else
            {
                projects = repository.GetAllProjectsByClientId(client.ClientID);
                return(View(projects));
            }
        }
示例#7
0
        public IViewComponentResult Invoke(string email)
        {
            Client client = new Models.Client();

            client = clientRepo.GetClientByEmail(email);
            List <Invoice> invoices = new List <Invoice>();

            if (client == null)
            {
                return(View(invoices));
            }
            else
            {
                invoices = repository.GetAllInvoicesByClientId(client.ClientID);
                return(View(invoices));
            }
        }