public async Task <ActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            ViewBag.id = id;
            var quoteInfo = db.GetProjectInfoByProjectID(id).FirstOrDefault();

            ViewBag.Activities      = db.GetProjectInfoActivitiesByProjectID(id).ToList();
            ViewBag.ProjectContacts = db.GetProjectContactsByProjectID(id).ToList();
            ViewBag.Parts           = db.GetProjectInfoPartsByProjectID(id).ToList();
            ViewBag.Contacts        = new SelectList(db.GetContactsBySiteCoID(siteusercompanyid).ToList(), nameof(GetContactsBySiteCoID_Result.ViewID), nameof(GetContactsBySiteCoID_Result.Customer));
            ViewBag.Builders        = new SelectList(db.GetBuildersBySiteCoID(siteusercompanyid).ToList(), nameof(GetBuildersBySiteCoID_Result.ViewID), nameof(GetBuildersBySiteCoID_Result.Builder));
            ViewBag.Relationships   = new SelectList(repo.GetProjectRelationshipsBySiteCoID(siteusercompanyid).ToList(), nameof(CoProjectRelationships.RelationshipID), nameof(CoProjectRelationships.Relationship));
            var ProjectInfo = db.GetProjectInfoByProjectID(id).FirstOrDefault();
            var dbx         = DropboxConnection();

            if (dbx != null)
            {
                var full = await dbx.Users.GetCurrentAccountAsync();

                var list = await dbx.Files.ListFolderAsync(string.Empty);

                foreach (var item in list.Entries.Where(i => i.IsFolder))
                {
                    if (item.Name == ProjectInfo.Project)
                    {
                        var sublist = await dbx.Files.ListFolderAsync("/" + item.Name);

                        ViewBag.FilesList = sublist.Entries.Where(i => i.IsFile).ToList();
                    }
                }
            }
            else
            {
                if (db.ProjectFiles.Where(s => s.ProjectID == id).FirstOrDefault() != null)
                {
                    List <ProjectFilesBOL> files = new List <ProjectFilesBOL>();
                    foreach (var ProjectFile in db.ProjectFiles.Where(s => s.ProjectID == id))
                    {
                        ProjectFilesBOL mt = new ProjectFilesBOL();
                        mt.Name           = ProjectFile.File;
                        mt.FilePath       = "files/" + siteusercompanyid + "/" + id + "/" + ProjectFile.File;
                        mt.FileId         = ProjectFile.ProjectFileID;
                        mt.ClientModified = ProjectFile.UploadedDateTime == null ? DateTime.Now : ProjectFile.UploadedDateTime.Value;
                        files.Add(mt);
                    }
                    if (files.Count > 0)
                    {
                        ViewBag.FilesList   = files;
                        ViewBag.LocalFolder = true;
                    }
                }
            }
            return(View(quoteInfo));
        }
        public ActionResult Create(int?contactid, int?quoteid, string from)
        {
            var siteCoID  = siteusercompanyid;
            var siteUsers = db.GetSiteUsersBySiteCoID(siteCoID).ToList();

            ViewBag.Clients       = new SelectList(db.GetContactsBySiteCoID(siteCoID).ToList(), "ViewID", "Customer", contactid);
            ViewBag.ProjectStatus = new SelectList(db.GetJobStatusBySiteCoID(siteCoID), "ViewID", "Name");
            ViewBag.SiteUsers     = new SelectList(siteUsers, "ViewID", "User");
            ViewBag.Builders      = new SelectList(db.GetBuildersBySiteCoID(siteCoID).ToList(), "ViewID", "Builder", contactid);
            qbModels = new QBModels();
            qbModels.SyncObjectsModel    = new QBSyncdto();
            qbModels.OAuthorizationModel = new QBAuthorizationdto();
            qbModels.IsReadySync         = false;
            var oAuthModel = new QBOAuthService(qbModels.OAuthorizationModel).IsTokenAvailable(this, siteusercompanyid);

            ViewBag.IsQBConnected = "false";
            if (oAuthModel.IsConnected)
            {
                ViewBag.IsQBConnected = "true";
            }
            LoadAdditionalDropdownData();
            JobModels.NewJob model = new JobModels.NewJob();
            var newJobId           = 0;

            if (quoteid.HasValue)
            {
                newJobId = repo.CopyQuoteTojob(quoteid.Value);
                model    = LoadProjectInfo(newJobId);
            }
            else
            {
                newJobId               = repo.GenerateNewProjectID();
                model.SalesPersonID    = siteuserid;
                model.ProjectManagerID = siteuserid;
                model.DesignerID       = siteuserid;
            }

            model.JobID     = newJobId;
            model.Date      = DateTime.Now;
            model.JobNumber = db.GetNewJobNumFormat(siteusercompanyid).FirstOrDefault();
            return(View(model));
        }
        public ActionResult Create(int?contactid)
        {
            var siteCoID = siteusercompanyid;

            ViewBag.Clients       = new SelectList(db.GetContactsBySiteCoID(siteCoID).ToList(), "ViewID", "Customer", contactid);
            ViewBag.ProjectStatus = new SelectList(db.GetLeadStatusBySiteCoID(siteCoID), "ViewID", "Status");
            ViewBag.Types         = new SelectList(repo.GetCoLeadTypes(siteCoID), "LeadTypeID", "LeadType");
            ViewBag.Probabilities = new SelectList(db.GetLeadProbabilityBySiteCoID(siteCoID), "ViewID", "LeadProp");
            ViewBag.Phases        = new SelectList(db.GetLeadStagesBySiteCoID(siteCoID), "ViewID", "LeadStage");
            ViewBag.Priorities    = new SelectList(db.GetLeadRatingsBySiteCoID(siteCoID), "ViewID", "LeadRating");
            ViewBag.Systems       = new SelectList(db.GetLeadSystemsBySiteCoID(siteCoID), "ViewID", "LeadSystems");
            ViewBag.Builders      = new SelectList(db.GetBuildersBySiteCoID(siteCoID).ToList(), "ViewID", "Builder", contactid);

            var siteUsers = db.GetSiteUsersBySiteCoID(siteCoID).ToList();

            ViewBag.SiteUsers      = new SelectList(siteUsers, "ViewID", "User", siteuserid);
            ViewBag.ContactAddress = db.GetContactAddressByContactID(contactid).FirstOrDefault();
            LeadModels.NewLead model = new LeadModels.NewLead()
            {
                JobNumber = db.GetNewLeadNumFormat(siteusercompanyid).FirstOrDefault()
            };

            return(View(model));
        }