public ActionResult Create(Projects_SubProject projects_subproject)
        {
            if (Authorized(RoleType.SystemManager))
            {
                if (ModelState.IsValid)
                {
                    projects_subproject.CompanyId = CurrentUser.CompanyId;
                    projects_subproject.IsActive = true;

                    bool wasCreated;
                    using (SubProjectsRepository subProjectsRep = new SubProjectsRepository())
                    {
                        wasCreated = subProjectsRep.Create(projects_subproject);
                    }

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

                }
                else
                {
                    return Error(ModelState);
                }
            }
            else
            {
                return Error(Loc.Dic.error_no_permission);
            }
        }
Exemple #2
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Projects_SubProject EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToProjects_SubProject(Projects_SubProject projects_SubProject)
 {
     base.AddObject("Projects_SubProject", projects_SubProject);
 }
Exemple #3
0
 /// <summary>
 /// Create a new Projects_SubProject 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_SubProject CreateProjects_SubProject(global::System.Int32 id, global::System.DateTime creationDate, global::System.Int32 companyId, global::System.String name, global::System.Boolean isActive)
 {
     Projects_SubProject projects_SubProject = new Projects_SubProject();
     projects_SubProject.Id = id;
     projects_SubProject.CreationDate = creationDate;
     projects_SubProject.CompanyId = companyId;
     projects_SubProject.Name = name;
     projects_SubProject.IsActive = isActive;
     return projects_SubProject;
 }
        public ActionResult Edit(Projects_SubProject projects_subproject)
        {
            if (Authorized(RoleType.SystemManager))
            {
                Projects_SubProject subProjectFromDB;
                using (SubProjectsRepository subProjectsRep = new SubProjectsRepository())
                {
                    subProjectFromDB = subProjectsRep.GetEntity(projects_subproject.Id);

                    if (subProjectFromDB != null)
                    {
                        if (subProjectFromDB.CompanyId == CurrentUser.CompanyId)
                        {
                            subProjectFromDB.Name = projects_subproject.Name;

                            subProjectsRep.Update(subProjectFromDB);

                            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);
            }
        }