Exemplo n.º 1
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 ViewResult ViewBid(int bidID)
        {
            Bid   bid   = bidRepo.GetBidByID(bidID);
            VMBid vmbid = new VMBid();

            vmbid.BidID                     = bid.BidID;
            vmbid.BidRequestID              = bid.BidReq.BidRequestID;
            vmbid.CustomerFirst             = bid.User.FirstName;
            vmbid.CustomerLast              = bid.User.LastName;
            vmbid.ProjectDescription        = bid.BidReq.ProjectDescription;
            vmbid.RevisedProjectDescription = bid.RevisedProjectDescription;
            vmbid.MaterialsDescription      = bid.MaterialsDescription;
            vmbid.ProjectedTimeFrame        = bid.ProjectedTimeFrame;
            vmbid.ProposedStartDate         = bid.ProposedStartDate;
            vmbid.SupplyCost                = bid.SupplyCost;
            vmbid.TotalEstimate             = bid.TotalEstimate;
            bid.DateCreated                 = DateTime.Now;
            return(View(vmbid));
        }