public static PropertyModel[] GetProperties(DAL.Interface.ProjectsReader dal, int projectId) { IProperty[] propertiesFromDAL = dal.GetPropertiesDefinitions(projectId); PropertyModel[] outputProperties = new PropertyModel[propertiesFromDAL.Length]; for (int i = 0; i < propertiesFromDAL.Length; i++ ) { outputProperties[i] = new PropertyModel(propertiesFromDAL[i]); } return outputProperties; }
public static PropertyModel[] ExcludeProperties(ProjectsReader dal, PropertyModel[] propertiesFromProject) { IProperty[] propertiesFromDAL = dal.GetPropertiesDefinitions(); PropertyModel[] modeledProperties = new PropertyModel[propertiesFromDAL.Length]; for (int i = 0; i < propertiesFromDAL.Length; i++) { modeledProperties[i] = new PropertyModel(propertiesFromDAL[i]); } return modeledProperties.Except(propertiesFromProject).ToArray(); }
internal static string CreateNewProperty(int projectId, PropertyModel model, bool important, HttpContextWarker contexter) { ProjectsReader dal = new ProjectsReader(); IProject currentProject = dal.GetProject(projectId); String culture = contexter.GetCulture(); if (!contexter.CanModify(currentProject)) { return ResourcesHelper.GetText("NotEnoughRigts", culture); } try { dal.CreateNewProperty(model.Name, model.SystemName, model.Type, model.AvailableValuesAsArray); } catch (BadSystemNameException) { return ResourcesHelper.GetText("BadPropertySystemName", culture); } catch (BadPropertyTypeException) { return ResourcesHelper.GetText("BadPropertyType", culture); } catch (ConnectionException) { return ResourcesHelper.GetText("ConnectionError", culture); } catch (BadDisplayTypeNameException) { return ResourcesHelper.GetText("BadDisplayType", culture); } try { currentProject.AddProperty(model.SystemName, true, important, contexter.User.Identity.Name); } catch (ConnectionException e) { return ResourcesHelper.GetText("ConnectionError", contexter.GetCulture()); } return null; }
internal static PropertyModel[] GetVisibleProperties(ProjectsReader dal, int projectId) { IProject project = dal.GetProject(projectId); if(project == null) { return null; } List<PropertyModel> outputProperties = new List<PropertyModel>(); foreach (IValue value in project.GetValues()) { if (!value.Visible) { continue; } PropertyModel property = new PropertyModel(value.GetProperty()); property.IsImportant = value.Important; property.ProjectId = projectId; outputProperties.Add(property); } return outputProperties.ToArray(); }
public ActionResult CreationOfNewPropertyClick(PropertyModel model, int projectId) { HttpContextWarker contexter = new HttpContextWarker(HttpContext); String result = ProjectHelper.CreateNewProperty(projectId, model, true, contexter); if (result != null) { HttpContext.Response.StatusCode = 404; return Json(new { error = result }, JsonRequestBehavior.AllowGet); } return new EmptyResult(); }
public ActionResult CreationOfNewProperty(int projectId) { ViewData["projectId"] = projectId; HttpContextWarker cultureProvider = new HttpContextWarker(HttpContext); string culture = cultureProvider.GetCulture(); ViewData["projectId"] = projectId; ViewData["nameTitle"] = ResourcesHelper.GetText("Name", culture); ViewData["sysNameTitle"] = ResourcesHelper.GetText("SystemName", culture); ViewData["typeTitle"] = ResourcesHelper.GetText("Type", culture); ViewData["availableValuesTitle"] = ResourcesHelper.GetText("ValuesInEnumeration", culture); ViewData["isImportantTitle"] = ResourcesHelper.GetText("IsImportant", culture); PropertyModel model = new PropertyModel(); model.Name = ""; model.SystemName = ""; model.Type = "String"; model.AvailableValues = ""; ViewData["availableTypes"] = ProjectHelper.GetAvailableTypesForDropdown(); return PartialView("CreateProperty", model); }