示例#1
0
        public ActionResult Create(Projects_ParentProject projects_parentproject)
        {
            if (Authorized(RoleType.SystemManager))
            {
                if (ModelState.IsValid)
                {
                    projects_parentproject.CompanyId = CurrentUser.CompanyId;
                    projects_parentproject.IsActive = true;

                    bool wasCreated;
                    using (ParentProjectsRepository projectsRep = new ParentProjectsRepository())
                    {
                        wasCreated = projectsRep.Create(projects_parentproject);
                    }

                    if (wasCreated)
                        return RedirectToAction("Index");
                    else
                        return Error(Loc.Dic.error_projects_create_error);

                }
                else
                {
                    return Error(ModelState);
                }
            }
            else
            {
                return Error(Loc.Dic.error_no_permission);
            }
        }
示例#2
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Projects_ParentProject EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToProjects_ParentProject(Projects_ParentProject projects_ParentProject)
 {
     base.AddObject("Projects_ParentProject", projects_ParentProject);
 }
示例#3
0
        public ActionResult Edit(Projects_ParentProject projects_parentproject)
        {
            if (Authorized(RoleType.SystemManager))
            {
                Projects_ParentProject projectFromDB;
                using (ParentProjectsRepository projectsRep = new ParentProjectsRepository())
                {
                    projectFromDB = projectsRep.GetEntity(projects_parentproject.Id);

                    if (projectFromDB != null)
                    {
                        if (projectFromDB.CompanyId == CurrentUser.CompanyId)
                        {
                            projectFromDB.Name = projects_parentproject.Name;

                            projectsRep.Update(projectFromDB);

                            return RedirectToAction("Index");
                        }
                        else
                        {
                            return Error(Loc.Dic.error_no_permission);
                        }
                    }
                    else
                    {
                        return Error(Loc.Dic.error_projects_get_error);
                    }
                }
            }
            else
            {
                return Error(Loc.Dic.error_no_permission);
            }
        }
示例#4
0
 /// <summary>
 /// Create a new Projects_ParentProject object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="creationDate">Initial value of the CreationDate property.</param>
 /// <param name="companyId">Initial value of the CompanyId property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="isActive">Initial value of the IsActive property.</param>
 public static Projects_ParentProject CreateProjects_ParentProject(global::System.Int32 id, global::System.DateTime creationDate, global::System.Int32 companyId, global::System.String name, global::System.Boolean isActive)
 {
     Projects_ParentProject projects_ParentProject = new Projects_ParentProject();
     projects_ParentProject.Id = id;
     projects_ParentProject.CreationDate = creationDate;
     projects_ParentProject.CompanyId = companyId;
     projects_ParentProject.Name = name;
     projects_ParentProject.IsActive = isActive;
     return projects_ParentProject;
 }