コード例 #1
0
        // GET: Project
        public ActionResult Index()
        {
            _context = new ApplicationDbContext();

            List <Projects> projectsList = _context.Projects.Select(p => p).ToList <Projects>();

            /*List<Customers> customersList = (from c in _context.Customers.ToList()
             *                               from pj in _context.Projects.ToList()
             *                               where c.Id == pj.Customer
             *                               select c).ToList();*/
            List <Customers> customersList = new List <Customers>();

            foreach (int custID in projectsList.Select(pjId => pjId.Customer))
            {
                if (_context.Customers.ToList().FirstOrDefault(gId => gId.Id == custID) != null)
                {
                    customersList.Add(_context.Customers.ToList().FirstOrDefault(gId => gId.Id == custID));
                }
            }

            var viewModel = new ProjectsFormViewModel()
            {
                projects  = projectsList,
                customers = customersList
            };

            //  ListBlobs();
            return(View(viewModel));
        }
コード例 #2
0
        public ActionResult Save(ProjectsFormViewModel projectController)
        {
            _context = new ApplicationDbContext();
            if (projectController.project.Description == null || projectController.project.BeginTime == null || projectController.project.UntilTime == null || projectController.project.Title == null)
            {
                var viewModel = new ProjectsFormViewModel
                {
                    project = projectController.project, customer = projectController.customer
                };
                return(View("Create", viewModel));
            }
            if (_context.Projects.FirstOrDefault(c => c.Id == projectController.project.Id) == null)
            {
                projectController.project.Customer = projectController.customer.Id;
                var result = projectController.project;

                _context.Projects.Add(result);
            }
            else
            {
                Projects projects = _context.Projects.FirstOrDefault(c => c.Id == projectController.project.Id);

                projects.Customer       = projectController.customer.Id;
                projects.Title          = projectController.project.Title;
                projects.Description    = projectController.project.Description;
                projects.PriceInDollars = projectController.project.PriceInDollars;
                projects.isComplite     = projectController.project.isComplite;
                projects.BeginTime      = projectController.project.BeginTime;
                projects.UntilTime      = projectController.project.UntilTime;
            }


            _context.ProjectsGroups.RemoveRange(_context.ProjectsGroups.Select(ug => ug).Where(ug => ug.ProjId == projectController.project.Id).ToList());
            _context.SaveChanges();
            if (projectController.SelectedIDArray != null && projectController.SelectedIDArray.Count() > 0)
            {
                _context = new ApplicationDbContext();
                if (_context.Projects.FirstOrDefault(g => g.Id == projectController.project.Id) != null)
                {
                    foreach (string id in projectController.SelectedIDArray)
                    {
                        if (_context.Groups.FirstOrDefault(u => u.Id.ToString() == id) != null && _context.ProjectsGroups.Select(ug => ug).Where(g => g.GroupId.ToString() == id && g.ProjId == projectController.project.Id).Count() == 0)
                        {
                            _context.ProjectsGroups.Add(new ProjectsGroups()
                            {
                                ProjId = projectController.project.Id, GroupId = Convert.ToInt32(id)
                            });
                        }
                    }
                    _context.SaveChanges();
                }
            }
            return(RedirectToAction("Index", "Project"));
        }
コード例 #3
0
        public ActionResult Create()
        {
            _context = new ApplicationDbContext();
            List <Customers> customersList = _context.Customers.Select(c => c).ToList <Customers>();
            List <Groups>    groupList     = _context.Groups.Select(g => g).ToList <Groups>();
            var viewModel = new ProjectsFormViewModel
            {
                project   = new Projects(),
                customers = customersList,
                groups    = groupList
            };

            return(View(viewModel));
        }
コード例 #4
0
        // GET: FileStorage
        public ActionResult Index()
        {
            /////files

            CloudBlobContainer container = GetCloudBlobContainer();
            string             con       = container.Name;
            List <string>      blobs     = new List <string>();
            string             userID    = User.Identity.GetUserId();

            foreach (IListBlobItem item in container.ListBlobs(useFlatBlobListing: true))
            {
                //if(item.Parent.Container.Name == "8")
                if (item.GetType() == typeof(CloudBlockBlob))
                {
                    CloudBlockBlob blob     = (CloudBlockBlob)item;
                    string[]       namePart = blob.Name.Split('/');
                    if (namePart != null && namePart.Count() > 0 && namePart[0] == userID)
                    {
                        blobs.Add(blob.Name);
                    }
                }
                else if (item.GetType() == typeof(CloudPageBlob))
                {
                    CloudPageBlob blob = (CloudPageBlob)item;
                    blobs.Add(blob.Name);
                }
                else if (item.GetType() == typeof(CloudBlobDirectory))
                {
                    CloudBlobDirectory dir = (CloudBlobDirectory)item;
                    blobs.Add(dir.Uri.ToString());
                }
            }
            /////files

            var viewModel = new ProjectsFormViewModel
            {
                filelist = blobs
            };

            return(View(viewModel));
        }
コード例 #5
0
        public ActionResult Edit(int id)
        {
            _context      = new ApplicationDbContext();
            Session["id"] = id;
            Projects project = _context.Projects.FirstOrDefault(gr => gr.Id == id);

            if (project == null)
            {
                return(RedirectToAction("Index", "Project"));
            }

            Customers        customer      = _context.Customers.FirstOrDefault(c => c.Id == project.Customer);
            List <Customers> customersList = _context.Customers.Select(c => c).ToList <Customers>();
            List <Groups>    groupList     = _context.Groups.Select(g => g).ToList <Groups>();
            var projectGroup = (from u in _context.Groups.ToList()
                                from gu in _context.ProjectsGroups.ToList()
                                where gu.ProjId == @project.Id && gu.GroupId == u.Id
                                select u).ToList();


            CloudBlobContainer container = GetCloudBlobContainer();
            string             con       = container.Name;
            List <string>      blobs     = new List <string>();
            int    sessionData           = (int)Session["id"];
            string projectID             = Convert.ToString(sessionData);

            foreach (IListBlobItem item in container.ListBlobs(useFlatBlobListing: true))
            {
                //if(item.Parent.Container.Name == "8")
                if (item.GetType() == typeof(CloudBlockBlob))
                {
                    CloudBlockBlob blob     = (CloudBlockBlob)item;
                    string[]       namePart = blob.Name.Split('/');
                    if (namePart != null && namePart.Count() > 0 && namePart[0] == projectID)
                    {
                        blobs.Add(blob.Name);
                    }
                }
                else if (item.GetType() == typeof(CloudPageBlob))
                {
                    CloudPageBlob blob = (CloudPageBlob)item;
                    blobs.Add(blob.Name);
                }
                else if (item.GetType() == typeof(CloudBlobDirectory))
                {
                    CloudBlobDirectory dir = (CloudBlobDirectory)item;
                    blobs.Add(dir.Uri.ToString());
                }
            }
            var viewModel = new ProjectsFormViewModel
            {
                project         = project, customer = customer,
                customers       = customersList,
                groups          = groupList,
                groupsInProject = projectGroup,
                filelist        = blobs
            };

            viewModel.SelectedIDArray = viewModel.groupsInProject.Select(u => u.Id.ToString()).ToArray();
            return(View(viewModel));
        }