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

            var corInfo = db.GetCorInfoByCorID(id).FirstOrDefault();
            var cor     = db.ProjectCor.Where(p => p.CorID == id).FirstOrDefault();

            if (corInfo == null || cor == null)
            {
                return(HttpNotFound());
            }

            ViewBag.Scope     = cor.Reason;
            ViewBag.Additions = db.GetCorInfoPartsAddedByCorID(id).ToList();
            ViewBag.Removals  = db.GetCorInfoPartsRemovedByCorID(id).ToList();
            int projectId = cor.ProjectID.HasValue ? cor.ProjectID.Value : 0;

            ViewBag.ProjectID  = projectId;
            ViewBag.IsApproved = cor.Approved;
            var ProjectInfo = db.GetProjectInfoByProjectID(projectId).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 == projectId).FirstOrDefault() != null)
                {
                    List <ProjectFilesBOL> files = new List <ProjectFilesBOL>();
                    foreach (var ProjectFile in db.ProjectFiles.Where(s => s.ProjectID == projectId))
                    {
                        ProjectFilesBOL mt = new ProjectFilesBOL();
                        mt.Name           = ProjectFile.File;
                        mt.FilePath       = "files/" + siteusercompanyid + "/" + projectId + "/" + 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(corInfo));
        }