コード例 #1
0
        public ActionResult Pay(int Id, CreditViewModel credit)
        {
            Project project = db.ProjectSet.FirstOrDefault(q => q.Id == Id);

            if (ModelState.IsValid)
            {
                ProjectAccess access = new ProjectAccess();
                access.UserId    = UserHelper.Current().Id;
                access.ProjectId = project.Id;

                Payment payment = new Payment();
                payment.Amount        = project.Price;
                payment.Date          = DateTime.Now;
                payment.UserId        = UserHelper.Current().Id;
                payment.ProjectAccess = access;
                db.PaymentSet.Add(payment);

                db.SaveChanges();

                return(RedirectToAction("Success"));
            }

            ViewBag.project = project;

            return(View("Index"));
        }
コード例 #2
0
        /// <summary>
        /// Get inscriptions of the project
        /// </summary>
        private void getInscriptions()
        {
            ProjectAccess projectAccess = new ProjectAccess();

            Hashtable projects = projectAccess.getProjectInscriptions();

            foreach (DictionaryEntry projectEntry in projects)
            {
                Project project = (Project)projectEntry.Value;

                TableRow newProject = new TableRow();
                InscriptionsTable.Controls.Add(newProject);

                TableCell cellTitle = new TableCell();
                cellTitle.Text = project.Name;
                newProject.Controls.Add(cellTitle);

                string personInscription = "<ul>\n";
                foreach (Person person in project.Inscriptions)
                {
                    personInscription += "<li>" + person.CompleteName + "</li>\n";
                }
                personInscription += "</ul>";

                TableCell cellInscriptions = new TableCell();
                cellInscriptions.Text = personInscription;
                newProject.Controls.Add(cellInscriptions);

                TableCell cellInscription = new TableCell();
            }
        }
コード例 #3
0
        public ActionResult Pay(CreditViewModel credit)
        {
            var carts = getCarts();

            if (ModelState.IsValid)
            {
                foreach (var cart in carts)
                {
                    ProjectAccess access = new ProjectAccess();
                    access.UserId    = UserHelper.Current().Id;
                    access.ProjectId = cart.ProjectId;

                    Payment payment = new Payment();
                    payment.Amount        = cart.Project.Price;
                    payment.Date          = DateTime.Now;
                    payment.UserId        = UserHelper.Current().Id;
                    payment.ProjectAccess = access;
                    db.PaymentSet.Add(payment);

                    cart.Status = CartStatus.Paid;
                }

                db.SaveChanges();

                return(RedirectToAction("Success"));
            }

            ViewBag.Amount = carts.Sum(q => q.Project.Price);
            return(View("PayForm"));
        }
コード例 #4
0
        public async Task <IActionResult> Edit(int id, int projectAccessId, [Bind("ProjectAccessId,UserId,ProjectId,AccessLevelId")] ProjectAccess projectAccess)
        {
            if (projectAccessId != projectAccess.ProjectAccessId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(projectAccess);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProjectAccessExists(projectAccess.ProjectAccessId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AccessLevelId"] = new SelectList(_context.AccessLevels, "AccessLevelId", "AccessName", projectAccess.AccessLevelId);
            ViewData["UserId"]        = new SelectList(_context.Users, "Id", "Id", projectAccess.UserId);
            return(View(projectAccess));
        }
コード例 #5
0
ファイル: Project.aspx.cs プロジェクト: rodolfolm/Lanban
        //1. Load all projects
        protected async Task loadProject(int userID, int role)
        {
            // Fetch all projects belong to or under supervised of this user
            ProjectAccess myAccess = new ProjectAccess();

            myAccess.fetchProject(userID, role);
            var project = myAccess.MyDataSet.Tables["Project"];

            Task task1 = Task.Run(() =>
            {
                for (int i = 0; i < project.Rows.Count; i++)
                {
                    var row = project.Rows[i];
                    projectbrowser.Controls.Add(ProjectBox(row));
                }
            });

            // Send project list in JSON to client for further processing
            Task task2 = Task.Run(() =>
            {
                StringBuilder projectList = new StringBuilder("var projectList = ");
                projectList.Append(JsonConvert.SerializeObject(project));
                projectList.Append(";");
                lists.Append(projectList);
            });

            await Task.WhenAll(task1, task2);

            myAccess.Dipose();
        }
コード例 #6
0
        public async Task <IActionResult> Create([Bind("ProjectId,ProjectName,ProjectSmallBrief,ProjectBrief,FilePath,UserId")] Project project)
        {
            if (ModelState.IsValid)
            {
                _context.Add(project);
                await _context.SaveChangesAsync();

                var projectAccess = new ProjectAccess()
                {
                    ProjectId     = project.ProjectId,
                    UserId        = project.UserId,
                    AccessLevelId = 1
                };
                _context.ProjectAccesses.Add(projectAccess);
                await _context.SaveChangesAsync();

/*                var sectionAdded = new Section()
 *              {
 *                  ProjectId = project.ProjectId,
 *                  SectionName = "EmptySectionNullSection1.2.3.4.5"
 *              };
 *              _context.Sections.Add(sectionAdded);
 *              await _context.SaveChangesAsync();*/

                return(RedirectToAction(nameof(Index)));
            }
            return(View(project));
        }
コード例 #7
0
        public ActionResult DeleteConfirmed(int id)
        {
            ProjectAccess projectAccess = db.ProjectAccessSet.Find(id);

            db.ProjectAccessSet.Remove(projectAccess);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #8
0
        protected void EmployeeIDDropDownList_SelectedIndexChanged(object sender, EventArgs e)
        {
            ProjectModel  projectModel = new ProjectModel();
            ProjectAccess projAccess   = new ProjectAccess();

            projectModel             = projAccess.GetProject(Convert.ToInt32(EmployeeIDDropDownList.SelectedValue));
            Project_NameTextBox.Text = projectModel.Project_Name;
            Client_NameTextBox.Text  = projectModel.Client_Name;
            LocationTextBox.Text     = projectModel.Location;
            RolesTextBox.Text        = projectModel.Roles;
        }
コード例 #9
0
        public async Task <IActionResult> Create(int id, [Bind("ProjectAccessId,UserId,ProjectId,AccessLevelId")] ProjectAccess projectAccess)
        {
            if (ModelState.IsValid)
            {
                _context.Add(projectAccess);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Details", "Projects", new { id = id }));
            }
            ViewData["AccessLevelId"] = new SelectList(_context.AccessLevels, "AccessLevelId", "AccessName", projectAccess.AccessLevelId);
            ViewData["UserId"]        = new SelectList(_context.Users, "Id", "Email", projectAccess.UserId);
            return(View(projectAccess));
        }
コード例 #10
0
 public ActionResult Edit([Bind(Include = "Id,ProjectId,UserId")] ProjectAccess projectAccess)
 {
     if (ModelState.IsValid)
     {
         db.Entry(projectAccess).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.UserId    = new SelectList(db.UserSet, "Id", "Name", projectAccess.UserId);
     ViewBag.ProjectId = new SelectList(db.ProjectSet, "Id", "Title", projectAccess.ProjectId);
     ViewBag.Id        = new SelectList(db.PaymentSet, "Id", "Id", projectAccess.Id);
     return(View(projectAccess));
 }
コード例 #11
0
        /// <summary>
        /// Displays the description of the project that is clicked.
        /// </summary>
        /// <param name="sender">Link on the project name</param>
        /// <param name="e">Arguments given to this command (project id)</param>
        public void description_Click(Object sender, EventArgs e)
        {
            ProjectAccess projectAccess = new ProjectAccess();

            // gets path to the xslt file
            string path = Path.Combine(System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath, @"xslt\fullProjectDescription.xslt");

            // Gets id of the project that must be displayed
            LinkButton description = sender as LinkButton;
            int idProject = Int32.Parse((string)description.CommandArgument);

            // Gets project data from database
            Project project = projectAccess.getProject(idProject);

            List<Technology> technos = projectAccess.getTechnologyProject(idProject);

            // Loads xslt file and executes the transformation to html. Result is stored in a StringWriter.
            string xml = "<project>\n";
            xml += "<title>" + project.Name + "</title>\n";
            xml += "<abreviation>" + project.Abreviation + "</abreviation>\n";
            xml += "<description>" + project.Description + "</description>\n";
            xml += "<nbStudent>" + project.NbStudents + "</nbStudent>\n";
            xml += "<technologies>\n";
            foreach(Technology techno in technos){
                xml += "<technology>" + techno.Name + "</technology>\n";
            }
            xml += "</technologies>\n";
            xml += "</project>\n";

            XPathDocument doc = new XPathDocument(new StringReader(xml));
            XslCompiledTransform xslt = new XslCompiledTransform();
            StringWriter sw = new StringWriter();

            xslt.Load(path);

            // get image from database
            byte[] image = projectAccess.getImage(idProject);

            if (image != null)
            {
                string encodedImage = "data:image/jpg;base64,";
                encodedImage += base64Encode(image);
                XsltArgumentList argsList = new XsltArgumentList();
                argsList.AddParam("IMAGE", "", encodedImage);
                xslt.Transform(doc, argsList, sw);
            }
            else
                xslt.Transform(doc, null, sw);

            descriptionPanel.Controls.Add(new LiteralControl(sw.ToString()));
        }
コード例 #12
0
        // GET: ProjectAccesses/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ProjectAccess projectAccess = db.ProjectAccessSet.Find(id);

            if (projectAccess == null)
            {
                return(HttpNotFound());
            }
            return(View(projectAccess));
        }
コード例 #13
0
        public ActionResult Create([Bind(Include = "Id,UserId,ProjectId")] ProjectAccess projectAccess)
        {
            if (ModelState.IsValid)
            {
                db.ProjectAccessSet.Add(projectAccess);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.UserId    = new SelectList(db.UserSet, "Id", "Name", projectAccess.UserId);
            ViewBag.ProjectId = new SelectList(db.ProjectSet, "Id", "Title", projectAccess.ProjectId);
            ViewBag.Id        = new SelectList(db.PaymentSet, "Id", "Amount", projectAccess.Id);
            return(View(projectAccess));
        }
コード例 #14
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         ProjectAccess obj       = new ProjectAccess();
         List <int>    EmpIDList = obj.GetEmployeeID();
         int           i         = 0;
         foreach (int EmpID in EmpIDList)
         {
             EmployeeIDDropDownList.Items.Insert(i, new ListItem(EmpID.ToString()));
             i++;
         }
     }
 }
コード例 #15
0
 public void Hook(ResourceHookType type, IResourceAccess access)
 {
     if (type == ResourceHookType.AfterDowngrade)
     {
         EventHandler <ProjectModifiedArgs> handler = ProjectModifiedEvent;
         if (handler != null)
         {
             ProjectAccess projAccess = access as ProjectAccess;
             foreach (ProjectModifiedArgs args in projAccess.toIssue)
             {
                 handler(this, args);
             }
         }
     }
 }
コード例 #16
0
        public void ProjectAccess_BasicProject_Test()
        {
            // arrange / given
            var project = new Project()
            {
                Name = "TEST-" + Guid.NewGuid().ToString()
            };

            // act / when
            var saved  = ProjectAccess.SaveProject(project);
            var loaded = ProjectAccess.Project(saved.Id);

            // assert / then
            Assert.IsNotNull(loaded);
            Assert.IsTrue(loaded.Id > 0);
        }
コード例 #17
0
        public void ProjectAccess_ProjectList_Test()
        {
            // arrange / given
            var start   = ProjectAccess.Projects();
            var project = new Project()
            {
                Name = "TEST-" + Guid.NewGuid().ToString()
            };

            // act / when
            var saved = ProjectAccess.SaveProject(project);
            var after = ProjectAccess.Projects();

            // assert / then
            Assert.AreEqual(start.Length + 1, after.Length);
        }
コード例 #18
0
ファイル: Project.aspx.cs プロジェクト: rodolfolm/Lanban
        // 2. Load users who share the same projects
        private void loadUser(int userID)
        {
            // Fetch data from database
            ProjectAccess myAccess = new ProjectAccess();

            myAccess.fetchSharedProjectUser(userID);
            var user = myAccess.MyDataSet.Tables["User"];

            // Send user list in JSON to client for further processing
            StringBuilder userList = new StringBuilder("var userList = ");

            userList.Append(JsonConvert.SerializeObject(user));
            userList.Append(";");
            lists.Append(userList);
            myAccess.Dipose();
        }
コード例 #19
0
        // GET: ProjectAccesses/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ProjectAccess projectAccess = db.ProjectAccessSet.Find(id);

            if (projectAccess == null)
            {
                return(HttpNotFound());
            }
            ViewBag.UserId    = new SelectList(db.UserSet, "Id", "Name", projectAccess.UserId);
            ViewBag.ProjectId = new SelectList(db.ProjectSet, "Id", "Title", projectAccess.ProjectId);
            ViewBag.Id        = new SelectList(db.PaymentSet, "Id", "Id", projectAccess.Id);
            return(View(projectAccess));
        }
コード例 #20
0
        /// <summary>
        /// Called when the page is loaded
        /// </summary>
        /// <param name="sender">Sender object of the event</param>
        /// <param name="e">Arguments of the event</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            int choosed_project = int.Parse(Request.QueryString.Get("id"));

            ProjectAccess projectAccess = new ProjectAccess();

            Stack<Project> history = projectAccess.getHistoryProject(choosed_project);

            int margin = 0;
            bool choosed_pass = false;

            while (history.Count != 0)
            {
                Project project = history.Pop();

                int pk_project = project.Id;
                string project_name = project.Name;

                if (!choosed_pass)
                {
                    string toAdd = "";
                    if (pk_project == choosed_project)
                    {
                        toAdd = "<div style='margin-left: " + margin + "px;'><strong>" + project_name + "</strong></div>\n";
                    }
                    else
                    {
                        toAdd = "<div style='margin-left: " + margin + "px;'>" + project_name + "</div>\n";
                    }
                    margin += 20;
                    historyMsg.Text += toAdd;

                    if (pk_project == choosed_project)
                    {
                        choosed_pass = true;
                    }
                }
                else
                {
                    string toAdd = "<div style='margin-left: " + margin + "px;'>" + project_name + "</div>\n";
                    historyMsg.Text += toAdd;
                }
            }
        }
コード例 #21
0
        public void ProjectAccess_BasicActivity_Test()
        {
            // arrange / given
            var activity = new Activity()
            {
                TaskName     = "TEST-" + Guid.NewGuid().ToString(),
                Estimate     = 0.5M,
                Start        = DateTime.Now,
                Finish       = DateTime.Now.AddDays(1),
                Predecessors = "",
                Resource     = "Dev1",
                ProjectId    = 0,
            };

            // act / when
            var saved  = ProjectAccess.SaveActivity(activity);
            var loaded = ProjectAccess.Activity(saved.Id);

            // assert / then
            Assert.IsNotNull(loaded);
            Assert.IsTrue(loaded.Id > 0);
        }
コード例 #22
0
        public void ProjectAccess_ActivitiesForProject_Test()
        {
            // arrange / given
            var activity = new Activity()
            {
                TaskName     = "TEST-" + Guid.NewGuid().ToString(),
                Estimate     = 0.5M,
                Start        = DateTime.Now,
                Finish       = DateTime.Now.AddDays(1),
                Predecessors = "",
                Resource     = "Dev1",
                ProjectId    = 99,
            };
            var before = ProjectAccess.ActivitiesForProject(99);

            // act / when
            var saved = ProjectAccess.SaveActivity(activity);
            var after = ProjectAccess.ActivitiesForProject(99);

            // assert / then
            Assert.AreEqual(before.Length + 1, after.Length);
        }
コード例 #23
0
 protected void AddProjectButton_Click(object sender, EventArgs e)
 {
     try
     {
         ProjectModel projectmodel = new ProjectModel()
         {
             EmployeeID   = Convert.ToInt32(EmployeeIDDropDownList.Text),
             Project_Name = Project_NameTextBox.Text,
             Client_Name  = Client_NameTextBox.Text,
             Location     = LocationTextBox.Text,
             Roles        = RolesTextBox.Text,
         };
         ProjectAccess projectdata = new ProjectAccess();
         string        Saveproj    = projectdata.SaveProject(projectmodel);
         if (Saveproj.Equals("Success"))
         {
             Response.Write("<script>alert('Details have been saved successfully');</script>");
         }
     }
     catch (Exception ex)
     {
         Response.Write("<script>alert('Please enter the values: '" + ex.Message + "); </ script > ");
     }
 }
コード例 #24
0
 protected void EditButton_Click(object sender, EventArgs e)
 {
     try
     {
         ProjectModel model = new ProjectModel()
         {
             EmployeeID   = Convert.ToInt32(EmployeeIDDropDownList.SelectedValue),
             Project_Name = Project_NameTextBox.Text,
             Client_Name  = Client_NameTextBox.Text,
             Location     = LocationTextBox.Text,
             Roles        = RolesTextBox.Text
         };
         ProjectAccess access  = new ProjectAccess();
         string        Editpro = access.EditProject(model);
         if (Editpro.Equals("Success"))
         {
             Response.Write("<script>alert('Details have been saved successfully');</script>");
         }
     }
     catch (Exception ex)
     {
         Response.Write("<script>alert('Please enter the values: '" + ex.Message + "); </script >");
     }
 }
コード例 #25
0
    /// <summary>
    /// Checks whether user is authorized per project access.
    /// </summary>
    public bool IsAuthorizedPerProjectAccess()
    {
        // Keep current user
        var cui = MembershipContext.AuthenticatedUser;

        // Switch by create project option
        switch (ProjectAccess.ToLowerCSafe())
        {
        // All users
        case "all":
            return(true);

        // Authenticated users
        case "authenticated":
            if (!cui.IsPublic())
            {
                return(true);
            }
            break;

        // Group members
        case "groupmember":
            if (CommunityGroupID > 0)
            {
                return(cui.IsGroupMember(CommunityGroupID));
            }
            break;

        // Authorized roles
        case "authorized":
            // Check whether roles are defined
            if (!String.IsNullOrEmpty(AuthorizedRoles))
            {
                // Check whether user is valid group member if current project is assigned to some group
                if (CommunityGroupID > 0)
                {
                    if (!cui.IsGroupMember(CommunityGroupID))
                    {
                        return(false);
                    }
                }

                // Keep site name
                string siteName = SiteContext.CurrentSiteName;
                // Split roles by semicolon
                string[] roles = AuthorizedRoles.Split(';');

                // Loop thru all roles and check if user is assigned at leat to one role
                foreach (string role in roles)
                {
                    // If user is in role, break current cycle and return true
                    if (cui.IsInRole(role, siteName))
                    {
                        return(true);
                    }
                }
            }
            break;

        // Nobody
        case "nobody":
        default:
            return(false);
        }

        return(false);
    }
コード例 #26
0
        public Model()
        {
            var databaseFactory = new SQLiteDatabaseFactory("connectionString");

            this.projectAccess = new ProjectAccess(databaseFactory);
        }
コード例 #27
0
        /// <summary>
        /// Create the list of projects for the table
        /// </summary>
        private void showProjects()
        {
            ProjectAccess projectAccess = new ProjectAccess();

            List<Project> projects = projectAccess.getFullProject();

            foreach (Project project in projects)
            {
                string clientName = projectAccess.getPersonCompletName(project.ClientId);
                List<Technology> technologys = projectAccess.getTechnologyProject(project.Id);
                List<Person> groups = projectAccess.getProjectGroup(project.Id);
                AddTableLine(project.Id.ToString(), project.Name, technologys, groups, clientName);
            }
        }
コード例 #28
0
 public ProjectHandlerOperation(AsyncCallback callback, HttpContext context, Object state)
     : base(callback, context, state)
 {
     myAccess = new ProjectAccess();
 }