protected void btnSaveAssetTypeChanges_Click(object sender, EventArgs e) { foreach (GridDataItem assetCategoryItem in rdAssetTypeGrid.Items) { GridNestedViewItem detailView = (GridNestedViewItem)assetCategoryItem.ChildItem; if (detailView != null) { GridTableView tableView = detailView.NestedTableViews.First(); foreach (GridDataItem assetTypeItem in tableView.Items) { Hashtable assetTypeValues = new Hashtable(); assetTypeItem.ExtractValues(assetTypeValues); int assetTypeId = Convert.ToInt32(assetTypeValues["AssetTypeId"].ToString()); AssetTypeEntity assetType = new AssetTypeEntity(assetTypeId); TextBox txtName = assetTypeItem.FindControl("txtName") as TextBox; TextBox txtAssetTypeDescription = assetTypeItem.FindControl("txtAssetTypeDescription") as TextBox; TextBox txtSpanishLabel = assetTypeItem.FindControl("txtSpanishLabel") as TextBox; DropDownList ddlAssetTypeCategory = assetTypeItem.FindControl("ddlAssetTypeCategory") as DropDownList; assetType.Name = txtName.Text.Trim().Length > 0 ? txtName.Text.Trim() : ""; assetType.Description = txtAssetTypeDescription.Text.Trim().Length > 0 ? txtAssetTypeDescription.Text.Trim() : ""; assetType.SpanishLabel = txtSpanishLabel.Text.Trim().Length > 0 ? txtSpanishLabel.Text.Trim() : ""; assetType.AssetCategoryId = Convert.ToInt32(ddlAssetTypeCategory.SelectedValue); assetType.Save(); } } } }
public async Task GetReportPositions_CorrectIdRoomWithoutNulls(int ReportId, int[] assetId, int[] assetTypeId, string[] assetName, char[] assetLetter, int[] prevRoom, int[] presentRoom, string[] roomName, int[] buildingId, string[] buildingName) { ReportPositionEntity[] reportPositionEntities = await apiController.getReportPositions(ReportId); for (int i = 0; i < assetId.Length; i++) { ReportPositionEntity tempReportPositionEntity = new ReportPositionEntity(); tempReportPositionEntity.present = Convert.ToBoolean(presentRoom[i]); AssetEntity tempAssetEntity = new AssetEntity(); tempAssetEntity.id = assetId[i]; AssetTypeEntity assetType = new AssetTypeEntity(); assetType.id = assetTypeId[i]; assetType.name = assetName[i]; assetType.letter = assetLetter[i]; tempAssetEntity.type = assetType; tempReportPositionEntity.asset = tempAssetEntity; RoomEntity tempRoomEntity = new RoomEntity(); tempRoomEntity.id = prevRoom[i]; tempRoomEntity.name = roomName[i]; BuildingEntity tempBuildingEntity = new BuildingEntity(); tempBuildingEntity.id = buildingId[i]; tempBuildingEntity.name = buildingName[i]; tempRoomEntity.building = tempBuildingEntity; tempReportPositionEntity.previous_room = tempRoomEntity; Assert.AreEqual(tempReportPositionEntity, reportPositionEntities[i]); } }
public async Task InsertAsync(AssetTypeWithTemplate model, IEnumerable <ClientProfileSettings> clientProfileSettingsToAdd) { var entity = new AssetTypeEntity { Id = model.Id, RegulatoryTypeId = model.RegulatoryTypeId, UnderlyingCategoryId = model.UnderlyingCategoryId, }; var clientProfileSettingsEntities = clientProfileSettingsToAdd.Select(ClientProfileSettingsEntity.Create).ToArray(); using (var context = _contextFactory.CreateDataContext()) { context.AssetTypes.Add(entity); context.ClientProfileSettings.AddRange(clientProfileSettingsEntities); try { await context.SaveChangesAsync(); } catch (DbUpdateException e) { if (e.InnerException is SqlException sqlException && sqlException.Number == MsSqlErrorCodes.PrimaryKeyConstraintViolation) { throw new AlreadyExistsException(); } throw; } } }
public async Task GetAssetInfoTest(int id, int typeId, char typeLetter, string typeName, int roomId, string roomName, int buildingId, string buildingName) { AssetTypeEntity assetTypeEntity = new AssetTypeEntity { id = typeId, letter = typeLetter, name = typeName }; BuildingEntity buildingEntity = new BuildingEntity { id = buildingId, name = buildingName }; RoomEntity roomEntity = new RoomEntity { id = roomId, name = roomName, building = buildingEntity }; AssetInfoEntity expected = new AssetInfoEntity { id = id, type = assetTypeEntity, room = roomEntity }; Assert.AreEqual(expected, await apiController.getAssetInfo(id)); }
protected void rdAssetTypeGrid_OnItemDataBound(object sender, GridItemEventArgs e) { if (e.Item is GridDataItem) { if (e.Item.OwnerTableView.Name == "AssetTypeView") { var assetCategories = from ac in _db.AssetCategory orderby ac.Name select ac; AssetTypeEntity assetType = e.Item.DataItem as AssetTypeEntity; DropDownList ddlAssetTypeCategory = e.Item.FindControl("ddlAssetTypeCategory") as DropDownList; if (ddlAssetTypeCategory != null) { foreach (AssetCategoryEntity ace in assetCategories) { ListItem li = new ListItem(ace.Name, ace.AssetCategoryId.ToString()); ddlAssetTypeCategory.Items.Add(li); } ddlAssetTypeCategory.SelectedValue = assetType.AssetCategoryId.ToString(); } //foreach (GridDataItem assetTypeDataItem in e.Item.OwnerTableView.Items) //{ // Hashtable assetTypeValues = new Hashtable(); // assetTypeDataItem.ExtractValues(assetTypeValues); // int assetTypeId = Convert.ToInt32(assetTypeValues["AssetTypeId"].ToString()); // DropDownList ddlAssetTypeCategory = dataItem.FindControl("ddlAssetTypeCategory") as DropDownList; // if (ddlAssetCategory != null) // { // foreach (AssetCategoryEntity ace in assetCategories) // { // ListItem li = new ListItem(ace.Name, ace.AssetCategoryId.ToString()); // ddlAssetCategory.Items.Add(li); // } // } //} } } }
protected void btnSaveAssetType_Click(object sender, EventArgs e) { if (txtAssetTypeName.Text.Trim().Length > 0) { AssetTypeEntity ate = new AssetTypeEntity(); ate.Name = txtAssetTypeName.Text.Trim(); ate.AssetCategoryId = Convert.ToInt32(ddlAssetCategory.SelectedItem.Value); ate.Description = txtAssetTypeDescription.Text.Trim().Length > 0 ? txtAssetTypeDescription.Text.Trim() : null; ate.SpanishLabel = txtAssetTypeSpanishLabel.Text.Trim().Length > 0 ? txtAssetTypeSpanishLabel.Text.Trim() : null; ate.Save(); txtAssetTypeName.Text = ""; txtAssetTypeDescription.Text = ""; txtAssetTypeSpanishLabel.Text = ""; txtAssetTypeName.Focus(); rdAssetTypeGrid.Rebind(); } }