public ActionResult deletUnit(long id) { if (id != 0) { EditUnitModel editUnitModel = new EditUnitModel(id); if (editUnitModel.Unit != null) { if (!editUnitModel.inUse) { UnitManager unitManager = new UnitManager(); unitManager.Delete(editUnitModel.Unit); } } } return RedirectToAction("UnitManager"); }
public JsonResult getDatatypeList(string Id) { long tempId = Convert.ToInt64(Id); UnitManager unitManager = new UnitManager(); Unit tempUnit = unitManager.Repo.Get(tempId); List<DataType> dataTypeList = new List<DataType>(); if (tempUnit.Name.ToLower() == "none") { DataTypeManager dataTypeManager = new DataTypeManager(); dataTypeList = dataTypeManager.Repo.Get().ToList(); dataTypeList = dataTypeList.OrderBy(p => p.Name).ToList(); } else { dataTypeList = unitManager.Repo.Get(tempId).AssociatedDataTypes.ToList(); dataTypeList = dataTypeList.OrderBy(p => p.Name).ToList(); } return Json(new SelectList(dataTypeList.ToArray(), "Id", "Name"), JsonRequestBehavior.AllowGet); }
public ActionResult editAttribute(DataAttributeModel Model) { ViewBag.Title = PresentationModel.GetViewTitleForTenant( "Manage Data Attributes", this.Session.GetTenant()); DataContainerManager dataAttributeManager = new DataContainerManager(); IList<DataAttribute> DataAttributeList = dataAttributeManager.DataAttributeRepo.Get(); long tempUnitId = Convert.ToInt64(Model.Unit.Id); long tempDataTypeId = Convert.ToInt64(Model.DataType.Id); Model.Id = Model.Id; Model.ShortName = cutSpaces(Model.ShortName); Model.Name = cutSpaces(Model.Name); Model.Description = cutSpaces(Model.Description); //if (Model.DomainConstraints.Count > 0) //{ // if (Model.DomainConstraints. != null && Model.DomainItems.Count > 0) // { // Model.DomainConstraints.FirstOrDefault().DomainItems = clearEmptyItems(Model.DomainItems); // } //} if (Model.Name == "" | Model.Name == null) { Session["nameMsg"] = "invalid Name"; Session["Window"] = true; return View("AttributeManager", new DataAttributeManagerModel(Model)); } else { bool nameNotExist = DataAttributeList.Where(p => p.Name.ToLower().Equals(Model.Name.ToLower())).Count().Equals(0); if (Model.Id == 0) { if (nameNotExist) { UnitManager UM = new UnitManager(); Unit unit = new Unit(); DataTypeManager DTM = new DataTypeManager(); DataType dataType = new DataType(); DataContainerManager DAM = new DataContainerManager(); DataAttribute temp = new DataAttribute(); if(UM.Repo.Get(tempUnitId)!= null) unit = UM.Repo.Get(tempUnitId); else unit = UM.Repo.Get().Where(u => u.Name.ToLower() == "none").FirstOrDefault(); if (DTM.Repo.Get(tempDataTypeId) != null) dataType = DTM.Repo.Get(tempDataTypeId); else dataType = DTM.Repo.Get().ToList().FirstOrDefault(); temp = DAM.CreateDataAttribute(Model.ShortName, Model.Name, Model.Description, false, false, "", MeasurementScale.Categorial, DataContainerType.ReferenceType, "", dataType, unit, null, null, null, null, null, null); #region store constraint if (Model.RangeConstraints.Count > 0 && (Model.RangeConstraints.FirstOrDefault().Min !=null || Model.RangeConstraints.FirstOrDefault().Max !=null) && (Model.RangeConstraints.FirstOrDefault().Min != 0.0 || Model.RangeConstraints.FirstOrDefault().Max != 0.0 )) temp = storeConstraint(Model.RangeConstraints.First(), temp); if (Model.PatternConstraints.Count > 0 && !String.IsNullOrEmpty(Model.PatternConstraints.FirstOrDefault().MatchingPhrase)) temp = storeConstraint(Model.PatternConstraints.First(), temp); if (Model.DomainConstraints.Count > 0) { foreach (DomainConstraintModel d in Model.DomainConstraints) { temp = storeConstraint(d, temp); } } #endregion temp = DAM.UpdateDataAttribute(temp); } else { Session["nameMsg"] = "Name already exist"; Session["Window"] = true; return View("AttributeManager", new DataAttributeManagerModel(Model)); } } else { if (nameNotExist || DataAttributeList.Where(p => p.Name.Equals(Model.Name)).ToList().First().Id == Model.Id) { DataAttribute dataAttribute = DataAttributeList.Where(p => p.Id.Equals(Model.Id)).ToList().First(); if (!attributeInUse(dataAttribute)) { DataContainerManager DAM = new DataContainerManager(); dataAttribute.Name = cutSpaces(Model.Name); dataAttribute.ShortName = Model.ShortName; dataAttribute.Description = Model.Description; UnitManager UM = new UnitManager(); if (UM.Repo.Get(tempUnitId) != null) dataAttribute.Unit = UM.Repo.Get(tempUnitId); else dataAttribute.Unit = UM.Repo.Get().Where(u => u.Name.ToLower() == "none").FirstOrDefault(); DataTypeManager DTM = new DataTypeManager(); if (DTM.Repo.Get(tempDataTypeId) != null) dataAttribute.DataType = DTM.Repo.Get(tempDataTypeId); else dataAttribute.DataType = DTM.Repo.Get().ToList().FirstOrDefault(); #region store constraint if (Model.RangeConstraints.Count > 0 && (Model.RangeConstraints.FirstOrDefault().Min != null || Model.RangeConstraints.FirstOrDefault().Max != null) && (Model.RangeConstraints.FirstOrDefault().Min != 0.0 || Model.RangeConstraints.FirstOrDefault().Max != 0.0)) dataAttribute = storeConstraint(Model.RangeConstraints.First(), dataAttribute); else dataAttribute = deletConstraint(Model.RangeConstraints.First().Id, dataAttribute); if (Model.PatternConstraints.Count > 0 && !String.IsNullOrEmpty(Model.PatternConstraints.FirstOrDefault().MatchingPhrase)) dataAttribute = storeConstraint(Model.PatternConstraints.First(), dataAttribute); else dataAttribute = deletConstraint(Model.PatternConstraints.First().Id, dataAttribute); if (Model.PatternConstraints.Count > 0 && !String.IsNullOrEmpty(Model.DomainConstraints.FirstOrDefault().Terms)) dataAttribute = storeConstraint(Model.DomainConstraints.First(), dataAttribute); else dataAttribute = deletConstraint(Model.DomainConstraints.First().Id, dataAttribute); #endregion DAM.UpdateDataAttribute(dataAttribute); } } else { Session["nameMsg"] = "Name already exist"; Session["Window"] = true; return View("AttributeManager", new DataAttributeManagerModel(Model)); } } } Session["Window"] = false; return RedirectToAction("AttributeManager"); }
public List<ItemStruct> getUnitListByDimenstionAndDataType(long dimensionId, long dataTypeId) { List<ItemStruct> UnitStructs = new List<ItemStruct>(); UnitManager unitmanager = new UnitManager(); List<Unit> units = new List<Unit>(); if(unitmanager.DimensionRepo.Get(dimensionId) != null) units = unitmanager.DimensionRepo.Get(dimensionId).Units.ToList(); ItemStruct tempUnitStruct = new ItemStruct(); foreach (Unit u in units) { if (u.Name.ToLower() != "none") { foreach (DataType dt in u.AssociatedDataTypes) { if (dt.Id == dataTypeId) { tempUnitStruct.Id = u.Id; tempUnitStruct.Name = u.Name; UnitStructs.Add(tempUnitStruct); break; } } } else { tempUnitStruct.Id = u.Id; tempUnitStruct.Name = u.Name; UnitStructs.Add(tempUnitStruct); } } return UnitStructs; }
public DataStructure CreateDataStructure(string dataSetID, DataTable mapVariables, List<string> variableNames) { DataStructureManager dataStructureManager = new DataStructureManager(); DataContainerManager attributeManager = new DataContainerManager(); StructuredDataStructure dataStructure = new StructuredDataStructure(); UnitManager unitManager = new UnitManager(); // values of DataStructure ExcelTemplateProvider provider = new ExcelTemplateProvider(); string name = "oldBExIS" + dataSetID; string description = "old BExIS datastructure, created for " + dataSetID + ", possibly used by other"; //metadata.Title; string xsdFileName = "";//"xsdFileName"; string xslFileName = "";//"xslFileName"; DataStructureCategory indexerType = DataStructureCategory.Generic; // if dataStructure not exists StructuredDataStructure existDS = existingDataStructures(mapVariables, dataSetID); if (existDS.Name == null) { // create dataStructure dataStructure = dataStructureManager.CreateStructuredDataStructure(name, description, xsdFileName, xslFileName, indexerType, null); foreach (string varName in variableNames) { // values of variables string attName = ""; string convFactor = ""; string varDescription = ""; int Block = -999; long AttributeId = -999, UnitId = -999, VarUnitId = -999; foreach (DataRow mapRow in mapVariables.Select("DatasetId = '" + dataSetID + "'")) { if (mapRow["Name"].ToString() == varName) { attName = mapRow["Attribute"].ToString(); convFactor = mapRow["ConvFactor"].ToString(); varDescription = mapRow["Description"].ToString(); Block = int.Parse(mapRow["Block"].ToString()); if (attName.Length > 1) // if not mapped yet { AttributeId = Convert.ToInt64(mapRow["AttributeId"].ToString()); UnitId = Convert.ToInt64(mapRow["UnitId"].ToString()); if (mapRow["Unit"].ToString().Length > 0) VarUnitId = Convert.ToInt64(mapRow["VarUnitId"].ToString()); } } } if (AttributeId > 0 && Block == 0) // if not mapped yet AND variable is in block 0 { // find existing attribute for each variable DataAttribute attribute = attributeManager.DataAttributeRepo.Get(AttributeId); Unit varUnit = null; if (VarUnitId > 0) { varUnit = unitManager.Repo.Get(VarUnitId); } // add variables to dataStructure Variable variable = dataStructureManager.AddVariableUsage(dataStructure, attribute, true, varName, null, null, varDescription, varUnit); dataStructure.Variables.Add(variable); } } provider.CreateTemplate(dataStructure); return dataStructure; } else { return existDS; } }
private void Add2UnitsAnd1ConversionUsingAPI() { UnitManager um = new UnitManager(); Unit km = um.Create("Kilometer", "Km", "This is the Kilometer", null, MeasurementSystem.Metric);// null dimension should be replaced Unit m = um.Create("Meter", "M", "This is the Meter", null, MeasurementSystem.Metric);// null dimension should be replaced Unit cm = um.Create("Centimeter", "Cm", "This is the CentiMeter which is equal to 0.01 Meter", null, MeasurementSystem.Metric); ConversionMethod cm1 = um.CreateConversionMethod("s*100", "Converts meter to centi meter", m, cm); ConversionMethod cm2 = um.CreateConversionMethod("s*1000", "Converts kilometer to meter", km, m); ConversionMethod cm3 = um.CreateConversionMethod("s/1000", "Converts meter to kilometer", m, km); ConversionMethod cm4 = um.CreateConversionMethod("s/100", "Converts centimeter to meter", cm, m); km.Description += "Updated"; cm1.Description += "Updated"; km.ConversionsIamTheSource.Clear(); //?? um.Update(km); um.UpdateConversionMethod(cm1); // Works fine: 24.07.12, Javad //DataTypeManager dtManager = new DataTypeManager(); //DataType deci = dtManager.Create("Decimal", "A decimal data type", TypeCode.Int16); //um.AddAssociatedDataType(m, deci); //um.RemoveAssociatedDataType(m, deci); um.DeleteConversionMethod(cm1); um.DeleteConversionMethod(new List<ConversionMethod>() { cm2, cm3 }); um.Delete(cm); um.Delete(new List<Unit>() { km, m }); }
public ActionResult _getDataTypes(long unitId) { List<ItemStruct> DataTypes = new List<ItemStruct>(); Unit unit = new UnitManager().Repo.Get(unitId); if (unit.Name.ToLower() != "none") { foreach (DataType dt in unit.AssociatedDataTypes) { DataTypes.Add(new ItemStruct() { Name = dt.Name, Id = dt.Id }); } return PartialView("_dataTypeDropdown", DataTypes.OrderBy(dt => dt.Name).ToList()); } else { foreach (DataType dt in new DataTypeManager().Repo.Get()) { DataTypes.Add(new ItemStruct() { Name = dt.Name, Id = dt.Id }); } return PartialView("_dataTypeDropdown", DataTypes.OrderBy(dt => dt.Name).ToList()); } }
public MessageModel storeAtttribute(long Id, string Name, long unitId, long dataTypeId, string Description = "", string cssId = "", bool inUse = false) { Name = Server.UrlDecode(Name); Description = Server.UrlDecode(Description); MessageModel DataStructureValidation = MessageModel.validateAttributeInUse(Id); if (DataStructureValidation.hasMessage && inUse == false) { return DataStructureValidation; } else { DataStructureValidation = MessageModel.validateAttributeName(Id, Name, cssId); if (DataStructureValidation.hasMessage) { return DataStructureValidation; } else { DataContainerManager dataAttributeManager = new DataContainerManager(); DataAttribute dataAttribute; if (Id == 0) { Unit unit = new UnitManager().Repo.Get(unitId); DataType dataType = new DataTypeManager().Repo.Get(dataTypeId); dataAttribute = dataAttributeManager.CreateDataAttribute(Name, Name, Description, false, false, "", MeasurementScale.Categorial, DataContainerType.ReferenceType, "", dataType, unit, null, null, null, null, null, null); return new MessageModel() { Message = dataAttribute.Id.ToString(), hasMessage = false, CssId = "refresh" }; } else { dataAttribute = dataAttributeManager.DataAttributeRepo.Get(Id); dataAttribute.Name = Name; dataAttribute.Description = Description; dataAttribute = dataAttributeManager.UpdateDataAttribute(dataAttribute); return new MessageModel() { Message = Id.ToString(), hasMessage = false, CssId = "refresh" }; } } } }
private void addDataTypes(long unitId, List<string> datatypeNames) { UnitManager unitManager = new UnitManager(); DataTypeManager dataTypeManger = new DataTypeManager(); Unit unit = unitManager.Repo.Get(unitId); // add bpp-dataTypes to the unit DataType dt = new DataType(); foreach (string type in datatypeNames) { dt = dataTypeManger.Repo.Get().Where(d => d.Name.ToLower().Equals(type.ToLower())).FirstOrDefault(); if (dt != null && !(unit.AssociatedDataTypes.Contains(dt))) unit.AssociatedDataTypes.Add(dt); } unitManager.Update(unit); }
// create read attributes in bpp public void CreateAttributes(ref DataTable mappedAttributes) { foreach (DataRow mapAttributesRow in mappedAttributes.Rows) { DataContainerManager attributeManager = new DataContainerManager(); DataTypeManager dataTypeManager = new DataTypeManager(); UnitManager unitManager = new UnitManager(); DataAttribute attribute = new DataAttribute(); // values of the attribute attribute.ShortName = mapAttributesRow["ShortName"].ToString(); attribute.Name = mapAttributesRow["Name"].ToString(); attribute.Description = mapAttributesRow["Description"].ToString(); attribute.IsMultiValue = false; attribute.IsBuiltIn = false; //attribute.Owner = "BMM"; attribute.Scope = ""; attribute.MeasurementScale = MeasurementScale.Categorial; ////////!!!!!!!!fromMapping?????????????????? attribute.ContainerType = DataContainerType.ReferenceType; attribute.EntitySelectionPredicate = ""; attribute.DataType = dataTypeManager.Repo.Get(Convert.ToInt64(mapAttributesRow["DataTypeId"])); attribute.Unit = unitManager.Repo.Get(Convert.ToInt64(mapAttributesRow["UnitId"])); attribute.Methodology = null; attribute.Classification = null; attribute.AggregateFunctions = null; attribute.GlobalizationInfos = null; attribute.Constraints = null; attribute.ExtendedProperties = null; DataAttribute dataAttribute = new DataAttribute(); DataAttribute existAttribute = attributeManager.DataAttributeRepo.Get(a => attribute.Name.Equals(a.Name) && attribute.ShortName.Equals(a.ShortName) && attribute.Unit.Id.Equals(a.Unit.Id) && attribute.DataType.Id.Equals(a.DataType.Id) ).FirstOrDefault(); // if attribute not exists (name, shortName) then create if (existAttribute == null) { dataAttribute = attributeManager.CreateDataAttribute( attribute.ShortName, attribute.Name, attribute.Description, attribute.IsMultiValue, attribute.IsBuiltIn, attribute.Scope, attribute.MeasurementScale, attribute.ContainerType, attribute.EntitySelectionPredicate, attribute.DataType, attribute.Unit, attribute.Methodology, attribute.Classification, attribute.AggregateFunctions, attribute.GlobalizationInfos, attribute.Constraints, attribute.ExtendedProperties ); } else { dataAttribute = existAttribute; } // add attributeId to the mappedAttributes Table mapAttributesRow["AttributeId"] = dataAttribute.Id; } }
// create read units in bpp public void CreateUnits(ref DataTable mappedUnits) { UnitManager unitManager = new UnitManager(); DataTypeManager dataTypeManger = new DataTypeManager(); Unit unit = new Unit(); foreach (DataRow mapUnitsRow in mappedUnits.Rows) { // values of the unit unit.Name = mapUnitsRow["Name"].ToString(); unit.Abbreviation = mapUnitsRow["Abbreviation"].ToString(); unit.Description = mapUnitsRow["Description"].ToString(); if (unit.Description.Length > 255) unit.Description = unit.Description.Substring(0, 255); unit.Dimension = unitManager.DimensionRepo.Get(Convert.ToInt64(mapUnitsRow["DimensionId"])); // find measurement system foreach (MeasurementSystem msCheck in Enum.GetValues(typeof(MeasurementSystem))) { if (msCheck.ToString().Equals(mapUnitsRow["MeasurementSystem"].ToString())) { unit.MeasurementSystem = msCheck; } } // set data type to created unit or add data type to existing unit List<string> Types = mapUnitsRow["DataTypes"].ToString().Split(' ').Distinct().ToList(); // get existing unit or create Unit existU = unitManager.Repo.Get(u => u.Abbreviation.Equals(unit.Abbreviation)).FirstOrDefault(); if (existU == null) { unit = unitManager.Create(unit.Name, unit.Abbreviation, unit.Description, unit.Dimension, unit.MeasurementSystem); addDataTypes(unit.Id, Types); } else { addDataTypes(existU.Id, Types); } // add unit-ID to the mappedUnits Table mapUnitsRow["UnitId"] = unit.Id; } }
// create dimensions in bpp public void CreateDimensions(ref DataTable mappedDimensions) { UnitManager unitManager = new UnitManager(); foreach (DataRow mappedDimension in mappedDimensions.Rows) { string dimensionName = mappedDimension["Name"].ToString(); string dimensionDescription = mappedDimension["Description"].ToString(); string dimensionSpecification = mappedDimension["Syntax"].ToString(); Dimension dimension = unitManager.DimensionRepo.Get().Where(d => d.Name.Equals(dimensionName)).FirstOrDefault(); if (dimension == null) { dimension = unitManager.Create(dimensionName, dimensionDescription, dimensionSpecification); } mappedDimension["DimensionId"] = dimension.Id; } }
public ActionResult editUnit(EditUnitModel Model, string measurementSystem, long[] checkedRecords) { ViewBag.Title = PresentationModel.GetViewTitleForTenant( "Manage Units", this.Session.GetTenant()); UnitManager unitManager = new UnitManager(); Model.Unit.Name = cutSpaces(Model.Unit.Name); Model.Unit.Abbreviation = cutSpaces(Model.Unit.Abbreviation); Model.Unit.Description = cutSpaces(Model.Unit.Description); Model.Unit.Dimension.Name = cutSpaces(Model.Unit.Dimension.Name); Model.Unit.Dimension.Specification = cutSpaces(Model.Unit.Dimension.Specification); if (Model.Unit.Id == 0) { if (unitValidation(Model.Unit, checkedRecords)) { foreach (MeasurementSystem msCheck in Enum.GetValues(typeof(MeasurementSystem))) { if (msCheck.ToString().Equals(measurementSystem)) { Model.Unit.MeasurementSystem = msCheck; } } if (Model.Unit.Dimension.Id != 0) Model.Unit.Dimension = unitManager.DimensionRepo.Get(Model.Unit.Dimension.Id); else { if (!String.IsNullOrEmpty(Model.Unit.Dimension.Name)) Model.Unit.Dimension.Name = "no Name"; Model.Unit.Dimension = unitManager.Create(Model.Unit.Dimension.Name, Model.Unit.Dimension.Name, Model.Unit.Dimension.Specification); } Model.Unit = unitManager.Create(Model.Unit.Name, Model.Unit.Abbreviation, Model.Unit.Description, Model.Unit.Dimension, Model.Unit.MeasurementSystem); updataAssociatedDataType(Model.Unit, checkedRecords); } else { Session["Window"] = true; return View("UnitManager", new UnitManagerModel()); } } else { if (unitValidation(Model.Unit, checkedRecords)) { Unit unit = unitManager.Repo.Get(Model.Unit.Id); if (!(unit.DataContainers.Count() > 0)) { unit.Name = Model.Unit.Name; unit.Description = Model.Unit.Description; unit.Abbreviation = Model.Unit.Abbreviation; foreach (MeasurementSystem msCheck in Enum.GetValues(typeof(MeasurementSystem))) { if (msCheck.ToString().Equals(measurementSystem)) { unit.MeasurementSystem = msCheck; } } if (Model.Unit.Dimension.Id != 0) unit.Dimension = unitManager.DimensionRepo.Get(Model.Unit.Dimension.Id); else { if (!String.IsNullOrEmpty(unit.Dimension.Name)) unit.Dimension.Name = "no Name"; unit.Dimension = unitManager.Create(Model.Unit.Dimension.Name, Model.Unit.Dimension.Name, Model.Unit.Dimension.Specification); } unit = unitManager.Update(unit); List<long> DataTypelIdList = new List<long>(); updataAssociatedDataType(unit, checkedRecords); } } else { Session["Window"] = true; return View("UnitManager", new UnitManagerModel(Model.Unit.Id)); } } Session["Window"] = false; Session["checked"] = null; return RedirectToAction("UnitManager"); }
private List<DataType> updataAssociatedDataType(Unit unit, long[] newDataTypeIds) { if (unit != null) { DataTypeManager dataTypeManger = new DataTypeManager(); UnitManager unitManager = new UnitManager(); unit = unitManager.Repo.Get(unit.Id); List<DataType> existingDataTypes = unit.AssociatedDataTypes.ToList(); List<DataType> newDataTypes = newDataTypeIds == null ? new List<DataType>() : dataTypeManger.Repo.Query().Where(p => newDataTypeIds.Contains(p.Id)).ToList(); List<DataType> tobeAddedDataTypes = newDataTypes.Except(existingDataTypes).ToList(); if (tobeAddedDataTypes != null && tobeAddedDataTypes.Count > 0) unitManager.AddAssociatedDataType(unit, tobeAddedDataTypes); unit = unitManager.Repo.Get(unit.Id); existingDataTypes = unit.AssociatedDataTypes.ToList(); List<DataType> toBeRemoved = existingDataTypes.Except(newDataTypes).ToList(); if (toBeRemoved != null && toBeRemoved.Count() > 0) unitManager.RemoveAssociatedDataType(unit, toBeRemoved); unit = unitManager.Repo.Get(unit.Id); return unit.AssociatedDataTypes.ToList(); } return null; }
private bool unitValidation(Unit unit, long[] checkedRecords) { bool check = true; UnitManager unitManager = new UnitManager(); List<Unit> unitList = unitManager.Repo.Get().ToList(); ; if (unit.Name == null || unit.Name == "") { Session["nameMsg"] = "invalid Name"; check = false; } else { bool nameExist = !(unitList.Where(p => p.Name.ToLower().Equals(unit.Name.ToLower())).Count().Equals(0)); if (nameExist) { Unit tempUnit = unitList.Where(p => p.Name.ToLower().Equals(unit.Name.ToLower())).ToList().First(); if (unit.Id != tempUnit.Id) { Session["nameMsg"] = "Name already exist"; check = false; } else { Session["nameMsg"] = null; } } else { Session["nameMsg"] = null; } } if (unit.Abbreviation == null || unit.Abbreviation == "") { Session["abbrMsg"] = "invalid Abbreviation"; check = false; } else { bool abbreviationExist = !(unitList.Where(p => p.Abbreviation.ToLower().Equals(unit.Abbreviation.ToLower())).Count().Equals(0)); if (abbreviationExist) { Unit tempUnit = unitList.Where(p => p.Abbreviation.ToLower().Equals(unit.Abbreviation.ToLower())).ToList().First(); if (unit.Id != tempUnit.Id) { Session["abbrMsg"] = "Abbreviation already exist"; check = false; } else { Session["abbrMsg"] = null; } } else { Session["abbrMsg"] = null; } } if (checkedRecords != null) { Session["dataTypeMsg"] = null; } else { Session["dataTypeMsg"] = "Choose at least one Data Type."; check = false; } if (!String.IsNullOrEmpty(unit.Dimension.Name) && unit.Dimension.Name != "Select or Enter") { Session["dimensionMsg"] = null; } else { Session["dimensionMsg"] = "Select or create an Dimension."; check = false; } return check; }
public ActionResult openUnitWindow(long id) { UnitManager unitManager = new UnitManager(); DataTypeManager dataTypeManager = new DataTypeManager(); UnitManagerModel Model; if (id != 0) { Model = new UnitManagerModel(id); ViewBag.Title = PresentationModel.GetViewTitleForTenant( "Edit Unit: " + Model.editUnitModel.Unit.Name + "(Id: " + Model.editUnitModel.Unit.Id + ")", this.Session.GetTenant()); Session["nameMsg"] = null; Session["abbrMsg"] = null; Session["dataTypeMsg"] = null; if (Model.editUnitModel.Unit != new Unit()) { Unit temp = Model.editUnitModel.Unit; if (temp.Id != Model.editUnitModel.Unit.Id) Session["checked"] = null; } Session["Window"] = true; Session["dimensionMsg"] = null; } else { ViewBag.Title = PresentationModel.GetViewTitleForTenant( "Create Unit", this.Session.GetTenant()); Model = new UnitManagerModel(); Session["nameMsg"] = null; Session["abbrMsg"] = null; Session["dataTypeMsg"] = null; Session["Window"] = true; Session["dimensionMsg"] = null; } return View("UnitManager", Model); }