public MaterialsViewModel() { this.Model = KanColleClient.Current.Homeport.Materials; var fuel = new MaterialViewModel("fuel", KanColleViewer.Properties.Resources.Homeport_Fuel_Short); var ammunition = new MaterialViewModel("ammunition", KanColleViewer.Properties.Resources.Homeport_Ammunition_Short); var steel = new MaterialViewModel("steel", KanColleViewer.Properties.Resources.Homeport_Steel_Short); var bauxite = new MaterialViewModel("bauxite", KanColleViewer.Properties.Resources.Homeport_Bauxite_Short); var develop = new MaterialViewModel("develop", KanColleViewer.Properties.Resources.Homeport_DevelopmentMaterials_Short); var repair = new MaterialViewModel("repair", KanColleViewer.Properties.Resources.Homeport_InstantRepair_Short); var build = new MaterialViewModel("build", KanColleViewer.Properties.Resources.Homeport_InstantBuild_Short); var improvement = new MaterialViewModel("improvement", KanColleViewer.Properties.Resources.Homeport_ImprovementMaterial_Short); var blank = new MaterialViewModel("blank", ""); this.Values = new List<MaterialViewModel> { fuel, ammunition, steel, bauxite, develop, repair, build, improvement, blank }; this._SelectedItem1 = this.Values.FirstOrDefault(x => x.Key == KanColleViewer.Models.Settings.Current.DisplayMaterial1) ?? fuel; this._SelectedItem2 = this.Values.FirstOrDefault(x => x.Key == KanColleViewer.Models.Settings.Current.DisplayMaterial2) ?? ammunition; this._SelectedItem3 = this.Values.FirstOrDefault(x => x.Key == KanColleViewer.Models.Settings.Current.DisplayMaterial3) ?? steel; this._SelectedItem4 = this.Values.FirstOrDefault(x => x.Key == KanColleViewer.Models.Settings.Current.DisplayMaterial4) ?? bauxite; this._SelectedItem5 = this.Values.FirstOrDefault(x => x.Key == KanColleViewer.Models.Settings.Current.DisplayMaterial5) ?? develop; this._SelectedItem6 = this.Values.FirstOrDefault(x => x.Key == KanColleViewer.Models.Settings.Current.DisplayMaterial6) ?? repair; this.Model.PropertyChanged += (sender, args) => { //args.PropertyName <--- Fuel, Ammunition, etc fuel.Value = this.Model.Fuel.ToString(); ammunition.Value = this.Model.Ammunition.ToString(); steel.Value = this.Model.Steel.ToString(); bauxite.Value = this.Model.Bauxite.ToString(); develop.Value = this.Model.DevelopmentMaterials.ToString(); repair.Value = this.Model.InstantRepairMaterials.ToString(); build.Value = this.Model.InstantBuildMaterials.ToString(); improvement.Value = this.Model.ImprovementMaterials.ToString(); }; KanColleClient.Current.Translations.PropertyChanged += (sender, args) => { fuel.Display = KanColleViewer.Properties.Resources.Homeport_Fuel_Short; ammunition.Display = KanColleViewer.Properties.Resources.Homeport_Ammunition_Short; steel.Display = KanColleViewer.Properties.Resources.Homeport_Steel_Short; bauxite.Display = KanColleViewer.Properties.Resources.Homeport_Bauxite_Short; develop.Display = KanColleViewer.Properties.Resources.Homeport_DevelopmentMaterials_Short; repair.Display = KanColleViewer.Properties.Resources.Homeport_InstantRepair_Short; build.Display = KanColleViewer.Properties.Resources.Homeport_InstantBuild_Short; improvement.Display = KanColleViewer.Properties.Resources.Homeport_ImprovementMaterial_Short; }; }
public MaterialDetails(User user, int materialID, bool readOnly) : base(user, "Material:" + materialID) { InitializeComponent(); var service = new MaterialService(user); var model = service.GetMaterial(materialID); _viewModel = new MaterialViewModel(model); _viewModel.DataChanged += new DataChangedHandler(viewModel_DataChanged); this.DataContext = _viewModel; this.IsReadOnly = readOnly; // General tab txtAccessionNumber.BindUser(User, "MaterialAccessionNo", "tblMaterial", "vchrAccessionNo"); txtRegistrationNumber.BindUser(User, "MaterialRegNo", "tblMaterial", "vchrRegNo" ); txtCollectorNo.BindUser(User, "MaterialCollectorNo", "tblMaterial", "vchrCollectorNo"); txtAbundance.BindUser(user, PickListType.Phrase, "Material Abundance", TraitCategoryType.Material); txtSource.BindUser(user, PickListType.Phrase, "Material Source", TraitCategoryType.Material); txtInstitution.BindUser(user, PickListType.Phrase, "Institution", TraitCategoryType.Material); txtCollectionMethod.BindUser(user, PickListType.Phrase, "Collection Method", TraitCategoryType.Material); txtMacroHabitat.BindUser(user, PickListType.Phrase, "Macro Habitat", TraitCategoryType.Material); txtMicroHabitat.BindUser(user, PickListType.Phrase, "Micro Habitat", TraitCategoryType.Material); txtTrap.BindUser(User, LookupType.Trap); // Identification tab txtIdentification.BindUser(User, LookupType.Taxon, LookupOptions.TaxonExcludeAvailableNames); txtIdentification.ObjectIDChanged += new ObjectIDChangedHandler(txtIdentification_ObjectIDChanged); txtIdentifiedBy.BindUser(User, "tblMaterial", "vchrIDBy"); txtReference.BindUser(User, LookupType.Reference); txtAccuracy.BindUser(User, PickListType.Phrase, "Identification Accuracy", TraitCategoryType.Material); txtMethod.BindUser(User, PickListType.Phrase, "Identification Method", TraitCategoryType.Material); txtNameQual.BindUser(User, PickListType.Phrase, "Identification Qualifier", TraitCategoryType.Material); _historyControl = new IdentificationHistoryControl(user, materialID); _historyControl.Margin = new Thickness(0); tabIDHistory.Content = _historyControl; var partsControl = new MaterialPartsControl(User, _viewModel) { IsReadOnly = readOnly }; tabMaterial.AddTabItem("Subparts", partsControl); tabMaterial.AddTabItem("Associates", new OneToManyControl(new AssociatesOneToManyController(User, TraitCategoryType.Material, _viewModel)) { IsReadOnly = readOnly }); tabMaterial.AddTabItem("Events", new CurationEventsControl(User, materialID, partsControl)); tabMaterial.AddTabItem("Labels", new MaterialLabelsControl(_viewModel)); tabMaterial.AddTabItem("Traits", new TraitControl(User, TraitCategoryType.Material, _viewModel) { IsReadOnly = readOnly }); tabMaterial.AddTabItem("Notes", new NotesControl(User, TraitCategoryType.Material, _viewModel) { IsReadOnly = readOnly }); tabMaterial.AddTabItem("Multimedia", new MultimediaControl(User, TraitCategoryType.Material, _viewModel) { IsReadOnly = readOnly }); tabMaterial.AddTabItem("Ownership", new OwnershipDetails(model)); if (!model.IsTemplate) { tabMaterial.AddTabItem("Summary", new MaterialSummary(User, _viewModel)); } }
public MaterialsViewModel() { this.Model = KanColleClient.Current.Homeport.Materials; var fuel = new MaterialViewModel(nameof(Materials.Fuel), "燃料").AddTo(this); this.Model.Subscribe(fuel.Key, () => fuel.Value = this.Model.Fuel).AddTo(this); var ammunition = new MaterialViewModel(nameof(Materials.Ammunition), "弾薬").AddTo(this); this.Model.Subscribe(ammunition.Key, () => ammunition.Value = this.Model.Ammunition).AddTo(this); var steel = new MaterialViewModel(nameof(Materials.Steel), "鋼鉄").AddTo(this); this.Model.Subscribe(steel.Key, () => steel.Value = this.Model.Steel).AddTo(this); var bauxite = new MaterialViewModel(nameof(Materials.Bauxite), "ボーキサイト").AddTo(this); this.Model.Subscribe(bauxite.Key, () => bauxite.Value = this.Model.Bauxite).AddTo(this); var develop = new MaterialViewModel(nameof(Materials.DevelopmentMaterials), "開発資材").AddTo(this); this.Model.Subscribe(develop.Key, () => develop.Value = this.Model.DevelopmentMaterials).AddTo(this); var repair = new MaterialViewModel(nameof(Materials.InstantRepairMaterials), "高速修復材").AddTo(this); this.Model.Subscribe(repair.Key, () => repair.Value = this.Model.InstantRepairMaterials).AddTo(this); var build = new MaterialViewModel(nameof(Materials.InstantBuildMaterials), "高速建造材").AddTo(this); this.Model.Subscribe(build.Key, () => build.Value = this.Model.InstantBuildMaterials).AddTo(this); var improvement = new MaterialViewModel(nameof(Materials.ImprovementMaterials), "改修資材").AddTo(this); this.Model.Subscribe(improvement.Key, () => improvement.Value = this.Model.ImprovementMaterials).AddTo(this); this.Values = new List<MaterialViewModel> { fuel, ammunition, steel, bauxite, develop, repair, build, improvement, }; this._SelectedItem1 = this.Values.FirstOrDefault(x => x.Key == KanColleSettings.DisplayMaterial1) ?? repair; this._SelectedItem2 = this.Values.FirstOrDefault(x => x.Key == KanColleSettings.DisplayMaterial2) ?? build; }
public MaterialSummary(User user, MaterialViewModel material) : base(user, "MaterialSummary:" + material.MaterialID) { InitializeComponent(); this.Material = material; }
public MaterialLabelsControl(MaterialViewModel model) { InitializeComponent(); this.DataContext = model; }
public CostCalculationGarmentViewModel MapToViewModel(CostCalculationGarment model) { CostCalculationGarmentViewModel viewModel = new CostCalculationGarmentViewModel(); PropertyCopier <CostCalculationGarment, CostCalculationGarmentViewModel> .Copy(model, viewModel); viewModel.Line = new LineViewModel(); viewModel.Line.Id = model.LineId; viewModel.Line.Name = model.LineName; viewModel.FabricAllowance = Percentage.ToPercent(model.FabricAllowance); viewModel.AccessoriesAllowance = Percentage.ToPercent(model.AccessoriesAllowance); viewModel.SizeRange = new SizeRangeViewModel(); viewModel.SizeRange.Id = model.SizeRangeId; viewModel.SizeRange.Name = model.SizeRangeName; viewModel.Buyer = new BuyerViewModel(); viewModel.Buyer.Id = model.BuyerId; viewModel.Buyer.Name = model.BuyerName; viewModel.Efficiency = new EfficiencyViewModel(); viewModel.Efficiency.Id = model.EfficiencyId; viewModel.Efficiency.Value = Percentage.ToPercent(model.EfficiencyValue); viewModel.Wage = new RateViewModel(); viewModel.Wage.Id = model.WageId; viewModel.Wage.Value = model.WageRate; viewModel.THR = new RateViewModel(); viewModel.THR.Id = model.THRId; viewModel.THR.Value = model.THRRate; viewModel.Rate = new RateViewModel(); viewModel.Rate.Id = model.RateId; viewModel.Rate.Value = model.RateValue; viewModel.CostCalculationGarment_Materials = new List <CostCalculationGarment_MaterialViewModel>(); if (model.CostCalculationGarment_Materials != null) { foreach (CostCalculationGarment_Material CostCalculationGarment_Material in model.CostCalculationGarment_Materials) { CostCalculationGarment_MaterialViewModel CostCalculationGarment_MaterialVM = new CostCalculationGarment_MaterialViewModel(); PropertyCopier <CostCalculationGarment_Material, CostCalculationGarment_MaterialViewModel> .Copy(CostCalculationGarment_Material, CostCalculationGarment_MaterialVM); CategoryViewModel categoryVM = new CategoryViewModel() { Id = CostCalculationGarment_Material.CategoryId }; string[] names = CostCalculationGarment_Material.CategoryName.Split(new[] { " - " }, StringSplitOptions.None); categoryVM.Name = names[0]; try { categoryVM.SubCategory = names[1]; } catch (IndexOutOfRangeException) { categoryVM.SubCategory = null; } CostCalculationGarment_MaterialVM.Category = categoryVM; MaterialViewModel materialVM = new MaterialViewModel() { Id = CostCalculationGarment_Material.MaterialId, Name = CostCalculationGarment_Material.MaterialName }; CostCalculationGarment_MaterialVM.Material = materialVM; UOMViewModel uomQuantityVM = new UOMViewModel() { Id = CostCalculationGarment_Material.UOMQuantityId, Name = CostCalculationGarment_Material.UOMQuantityName }; CostCalculationGarment_MaterialVM.UOMQuantity = uomQuantityVM; UOMViewModel uomPriceVM = new UOMViewModel() { Id = CostCalculationGarment_Material.UOMPriceId, Name = CostCalculationGarment_Material.UOMPriceName }; CostCalculationGarment_MaterialVM.UOMPrice = uomPriceVM; CostCalculationGarment_MaterialVM.ShippingFeePortion = Percentage.ToPercent(CostCalculationGarment_Material.ShippingFeePortion); viewModel.CostCalculationGarment_Materials.Add(CostCalculationGarment_MaterialVM); } } viewModel.CommissionPortion = Percentage.ToPercent(model.CommissionPortion); viewModel.Risk = Percentage.ToPercent(model.Risk); viewModel.OTL1 = new RateCalculatedViewModel(); viewModel.OTL1.Id = model.OTL1Id; viewModel.OTL1.Value = model.OTL1Rate; viewModel.OTL1.CalculatedValue = model.OTL1CalculatedRate; viewModel.OTL2 = new RateCalculatedViewModel(); viewModel.OTL2.Id = model.OTL2Id; viewModel.OTL2.Value = model.OTL2Rate; viewModel.OTL2.CalculatedValue = model.OTL2CalculatedRate; viewModel.NETFOBP = Percentage.ToPercent((double)model.NETFOBP); return(viewModel); }
public Product ConvertToProduct2(string condition = null, int?userDemand = null, decimal?Duration = null) { decimal?price = null; Dictionary <string, object> prodDict = new Dictionary <string, object>(); ProductValidator validator = new ProductValidator(); var config = new MapperConfiguration(cfg => { }); var mapper = new Mapper(config); if (this.ProductType.Equals("FoodAndBeverageItems")) { FoodBevItemViewModel food = mapper.Map <FoodBevItemViewModel>(this.ProductDetail); prodDict = food.fromItemToDict(); price = food.unitPriceItemCalculation(); validator.isValidProductDetail(prodDict, ProductType); } else if (this.ProductType.Equals("MaterialItems")) { MaterialViewModel materi = mapper.Map <MaterialViewModel>(this.ProductDetail); prodDict = materi.fromItemToDict(); price = materi.unitPriceItemCalculation(); validator.isValidProductDetail(prodDict, ProductType); } else if (this.ProductType.Equals("GarmentItems")) { GarmentViewModel garment = mapper.Map <GarmentViewModel>(this.ProductDetail); prodDict = garment.fromItemToDict(); price = garment.unitPriceItemCalculation(); validator.isValidProductDetail(prodDict, ProductType); } else if (this.ProductType.Equals("TransportationServices")) { TransportationServicesViewModel trans = mapper.Map <TransportationServicesViewModel>(this.ProductDetail); prodDict = trans.fromServToDict(); price = trans.RateCostCalculation(condition, userDemand, Duration); validator.isValidProductDetail(prodDict, ProductType); } else if (this.ProductType.Equals("TelecommunicationServices")) { TelecomunicationServiceViewModel tele = mapper.Map <TelecomunicationServiceViewModel>(this.ProductDetail); prodDict = tele.fromServToDict(); price = tele.RateCostCalculation(condition, userDemand, Duration); validator.isValidProductDetail(prodDict, ProductType); } else { price = 0; ProductDetail = null; } if (validator.isValidProductDetail(prodDict, ProductType)) { return(new Product() { ProductID = this.ProductID, ProductName = this.ProductName, SupplierID = this.SupplierID, CategoryID = this.CategoryID, QuantityPerUnit = this.QuantityPerUnit, UnitPrice = price, UnitsInStock = this.UnitsInStock, UnitsOnOrder = this.UnitsOnOrder, ReorderLevel = this.ReorderLevel, Discontinued = this.Discontinued, ProductType = this.ProductType, ProductDetail = prodDict.ToString() }); } else { return(null); } }
public async void MaterialViewModelGet() { // Arrange this.QuarryDbContext.MaterialColours.AddRange( new MaterialColourEntity() { MaterialColourId = 1, ColourName = "White", CompanyId = 1, DeletedInd = false }, new MaterialColourEntity() { MaterialColourId = 2, ColourName = "Smoky", CompanyId = 1, DeletedInd = false }); this.QuarryDbContext.ProductTypes.AddRange( new ProductTypeEntity() { ProductTypeId = 1, ProductTypeName = "Slab", CompanyId = 1, DeletedInd = false }, new ProductTypeEntity() { ProductTypeId = 2, ProductTypeName = "Tile", CompanyId = 1, DeletedInd = false }); this.QuarryDbContext.Quarries.AddRange( new QuarryEntity() { QuarryId = 1, QuarryName = "QM1", CompanyId = 1, DeletedInd = false }, new QuarryEntity() { QuarryId = 2, QuarryName = "QM2", CompanyId = 1, DeletedInd = false }); this.QuarryDbContext.Textures.AddRange( new TextureEntity() { TextureId = 1, TextureName = "Crystaline", CompanyId = 1, DeletedInd = false }, new TextureEntity() { TextureId = 2, TextureName = "Milky", CompanyId = 1, DeletedInd = false }); this.QuarryDbContext.ProcessTypes.AddRange( new ProcessTypeEntity() { ProcessTypeId = 1, ProcessTypeName = "Cutting", CompanyId = 1, DeletedInd = false }, new ProcessTypeEntity() { ProcessTypeId = 2, ProcessTypeName = "Crushing", CompanyId = 1, DeletedInd = false }); await this.SaveChangesAsync(this.QuarryDbContext); // Act AjaxModel <MaterialViewModel> ajaxModel = await this.Controller.MaterialViewModelGet(); MaterialViewModel viewModel = ajaxModel.Model; // Assert Assert.Equal(viewModel.MaterialColours[1].Item, "White"); Assert.Equal(viewModel.ProductTypes[1].ProductTypeName, "Tile"); Assert.Equal(viewModel.Quarries[1].Item, "QM2"); Assert.Equal(viewModel.Textures[1].Item, "Milky"); Assert.Equal(viewModel.ProcessTypes[1].Item, "Cutting"); }
/// <summary> /// Reads MaterialViewModel properties from XML and sets a MaterialViewModel with said properties. /// </summary> /// <param name="xmlReader"></param> /// <param name="materialViewModel"></param> public void DeserializerMaterial(XmlReader xmlReader, MaterialViewModel materialViewModel) { //Read through each element of the XML string and populate each property of the Material. PrintStyleXMLDeserializerModel printStyleXMLDeserializerModel = null; while (xmlReader.Read()) { //Skip through newlines (this program's XML Writer uses newlines). if ((xmlReader.Name != "\n") && (!String.IsNullOrWhiteSpace(xmlReader.Name))) { //End method if the end of "Material" element is reached. if ((xmlReader.Name == "Material") && (xmlReader.NodeType == XmlNodeType.EndElement)) { return; } switch (xmlReader.Name) { case "MaterialName": //See if there is a mismatch between the Material argument and the deserialized Material. if (xmlReader.ReadElementContentAsString() != materialViewModel.Name) { base.ReportErrorMismatchedEqupment(xmlReader); } break; case "RepRapID": materialViewModel.RepRapID = xmlReader.ReadElementContentAsString(); break; case "PrintheadName": materialViewModel.PrintheadViewModel = _printerViewModel.FindPrinthead(xmlReader.ReadElementContentAsString()); break; case "UnsetPrintStyle": //Do nothing. break; case "ContinuousPrintStyle": materialViewModel.PrintStyle = PrintStyle.Continuous; printStyleXMLDeserializerModel = new ContinuousPrintStyleXMLDeserializerModel(base._errorListViewModel); printStyleXMLDeserializerModel.DeserializePrintStyle(xmlReader, materialViewModel.PrintStyleViewModel); break; case "DropletPrintStyle": materialViewModel.PrintStyle = PrintStyle.Droplet; printStyleXMLDeserializerModel = new DropletPrintStyleXMLDeserializerModel(base._errorListViewModel); printStyleXMLDeserializerModel.DeserializePrintStyle(xmlReader, materialViewModel.PrintStyleViewModel); break; case "PauseAfterActivating": string pauseAfterActivatingContent = xmlReader.ReadElementContentAsString(); materialViewModel.PauseAfterActivating = (pauseAfterActivatingContent == "True") ? true : false; break; case "PauseBeforeDeactivating": string pauseBeforeDeactivatingContent = xmlReader.ReadElementContentAsString(); materialViewModel.PauseBeforeDeactivating = (pauseBeforeDeactivatingContent == "True") ? true : false; break; case "JunctionDeviation": materialViewModel.JunctionDeviation = xmlReader.ReadElementContentAsDouble(); break; case "XYPrintSpeed": materialViewModel.XYPrintSpeed = xmlReader.ReadElementContentAsDouble(); break; case "ZPrintSpeed": materialViewModel.ZPrintSpeed = xmlReader.ReadElementContentAsDouble(); break; case "XYPrintAcceleration": materialViewModel.XYPrintAcceleration = xmlReader.ReadElementContentAsDouble(); break; case "ZPrintAcceleration": materialViewModel.ZPrintAcceleration = xmlReader.ReadElementContentAsDouble(); break; default: base.ReportErrorUnrecognizedElement(xmlReader); break; } } } }
public ActionResult RetornarBusca(MaterialViewModel materialViewModel) { var lista = _materialAppService.RetornarListaPorDescricao(materialViewModel.Descricao); return(PartialView("_ListaDeMaterial", lista)); }
public CostCalculationRetailViewModel MapToViewModel(CostCalculationRetail model) { CostCalculationRetailViewModel viewModel = new CostCalculationRetailViewModel(); PropertyCopier <CostCalculationRetail, CostCalculationRetailViewModel> .Copy(model, viewModel); viewModel.Style = new ArticleStyleViewModel(); viewModel.Style._id = model.StyleId; viewModel.Style.name = model.StyleName; viewModel.Season = new ArticleSeasonViewModel(); viewModel.Season._id = model.SeasonId; viewModel.Season.name = model.SeasonName; viewModel.Buyer = new BuyerViewModel(); viewModel.Buyer.Id = model.BuyerId; viewModel.Buyer.Name = model.BuyerName; viewModel.SizeRange = new SizeRangeViewModel(); viewModel.SizeRange.Id = model.SizeRangeId; viewModel.SizeRange.Name = model.SizeRangeName; viewModel.FabricAllowance = Percentage.ToPercent(model.FabricAllowance); viewModel.AccessoriesAllowance = Percentage.ToPercent(model.AccessoriesAllowance); try { // Get Related Size of particular Size Range if possible viewModel.SizeRange.RelatedSizes = new List <RelatedSizeViewModel>(); Task <SizeRange> sizeRange = this.SizeRangeService.ReadModelById(model.SizeRangeId); sizeRange.Wait(); foreach (RelatedSize rs in sizeRange.Result.RelatedSizes) { RelatedSizeViewModel relatedSizeVM = new RelatedSizeViewModel(); PropertyCopier <RelatedSize, RelatedSizeViewModel> .Copy(rs, relatedSizeVM); SizeViewModel sizeVM = new SizeViewModel(); PropertyCopier <Size, SizeViewModel> .Copy(rs.Size, sizeVM); relatedSizeVM.Size = sizeVM; viewModel.SizeRange.RelatedSizes.Add(relatedSizeVM); } } catch (Exception) { // If cannot get Related Size, do nothing } viewModel.Counter = new ArticleCounterViewModel(); viewModel.Counter._id = model.CounterId; viewModel.Counter.name = model.CounterName; viewModel.Efficiency = new EfficiencyViewModel(); viewModel.Efficiency.Id = model.EfficiencyId; viewModel.Efficiency.Value = model.EfficiencyValue; viewModel.Risk = Percentage.ToPercent(model.Risk); viewModel.OL = new RateCalculatedViewModel(); viewModel.OL.Id = model.OLId; viewModel.OL.Value = model.OLRate; viewModel.OL.CalculatedValue = model.OLCalculatedRate; viewModel.OTL1 = new RateCalculatedViewModel(); viewModel.OTL1.Id = model.OTL1Id; viewModel.OTL1.Value = model.OTL1Rate; viewModel.OTL1.CalculatedValue = model.OTL1CalculatedRate; viewModel.OTL2 = new RateCalculatedViewModel(); viewModel.OTL2.Id = model.OTL2Id; viewModel.OTL2.Value = model.OTL2Rate; viewModel.OTL2.CalculatedValue = model.OTL2CalculatedRate; viewModel.OTL3 = new RateCalculatedViewModel(); viewModel.OTL3.Id = model.OTL3Id; viewModel.OTL3.Value = model.OTL3Rate; viewModel.OTL3.CalculatedValue = model.OTL3CalculatedRate; viewModel.CostCalculationRetail_Materials = new List <CostCalculationRetail_MaterialViewModel>(); if (model.CostCalculationRetail_Materials != null) { foreach (CostCalculationRetail_Material costCalculationRetail_Material in model.CostCalculationRetail_Materials) { CostCalculationRetail_MaterialViewModel costCalculationRetail_MaterialVM = new CostCalculationRetail_MaterialViewModel(); PropertyCopier <CostCalculationRetail_Material, CostCalculationRetail_MaterialViewModel> .Copy(costCalculationRetail_Material, costCalculationRetail_MaterialVM); CategoryViewModel categoryVM = new CategoryViewModel() { Id = costCalculationRetail_Material.CategoryId }; string[] names = costCalculationRetail_Material.CategoryName.Split(new[] { " - " }, StringSplitOptions.None); categoryVM.Name = names[0]; try { categoryVM.SubCategory = names[1]; } catch (IndexOutOfRangeException) { categoryVM.SubCategory = null; } costCalculationRetail_MaterialVM.Category = categoryVM; MaterialViewModel materialVM = new MaterialViewModel() { Id = costCalculationRetail_Material.MaterialId, Name = costCalculationRetail_Material.MaterialName }; costCalculationRetail_MaterialVM.Material = materialVM; UOMViewModel uomQuantityVM = new UOMViewModel() { Id = costCalculationRetail_Material.UOMQuantityId, Name = costCalculationRetail_Material.UOMQuantityName }; costCalculationRetail_MaterialVM.UOMQuantity = uomQuantityVM; UOMViewModel uomPriceVM = new UOMViewModel() { Id = costCalculationRetail_Material.UOMPriceId, Name = costCalculationRetail_Material.UOMPriceName }; costCalculationRetail_MaterialVM.UOMPrice = uomPriceVM; viewModel.CostCalculationRetail_Materials.Add(costCalculationRetail_MaterialVM); } } return(viewModel); }
public void ObtenerListado(ref MaterialViewModel viewModel, string colOrden = "", string ordenActual = "", int?numRegistros = 10, int?pagina = 1, string buscar = "") { int pageIndex = pagina.Value; List <MVKEMaterial> materiales = db.MATERIALVKEs.Join(db.MATERIALs, p => p.MATERIAL_ID, e => e.ID, (p, e) => new MVKEMaterial { MATERIAL_ID = p.MATERIAL_ID, VKORG = p.VKORG, VTWEG = p.VTWEG, MATKL_ID = e.MATKL_ID, MAKTX = e.MAKTX, MATERIAL_GROUP = e.MATERIALGP.DESCRIPCION, ACTIVO = p.ACTIVO }).Where(t => t.ACTIVO).ToList(); viewModel.ordenActual = (string.IsNullOrEmpty(ordenActual) || !colOrden.Equals(ordenActual) ? colOrden : ""); viewModel.numRegistros = numRegistros.Value; viewModel.buscar = buscar; if (!String.IsNullOrEmpty(buscar)) { materiales = materiales.Where(x => String.Concat(x.MATERIAL_ID, x.VKORG, x.VTWEG, x.MATKL_ID, x.MAKTX, x.MATERIAL_GROUP) .ToLower().Contains(buscar.ToLower())) .ToList(); } switch (colOrden) { case "MATERIAL_ID": if (colOrden.Equals(ordenActual)) { viewModel.materiales = materiales.OrderByDescending(m => m.MATERIAL_ID).ToPagedList(pageIndex, viewModel.numRegistros); } else { viewModel.materiales = materiales.OrderBy(m => m.MATERIAL_ID).ToPagedList(pageIndex, viewModel.numRegistros); } break; case "VKORG": if (colOrden.Equals(ordenActual)) { viewModel.materiales = materiales.OrderByDescending(m => m.VKORG).ToPagedList(pageIndex, viewModel.numRegistros); } else { viewModel.materiales = materiales.OrderBy(m => m.VKORG).ToPagedList(pageIndex, viewModel.numRegistros); } break; case "VTWEG": if (colOrden.Equals(ordenActual)) { viewModel.materiales = materiales.OrderByDescending(m => m.VTWEG).ToPagedList(pageIndex, viewModel.numRegistros); } else { viewModel.materiales = materiales.OrderBy(m => m.VTWEG).ToPagedList(pageIndex, viewModel.numRegistros); } break; case "MAKTX": if (colOrden.Equals(ordenActual)) { viewModel.materiales = materiales.OrderByDescending(m => m.MAKTX).ToPagedList(pageIndex, viewModel.numRegistros); } else { viewModel.materiales = materiales.OrderBy(m => m.MAKTX).ToPagedList(pageIndex, viewModel.numRegistros); } break; case "MATKL_ID": if (colOrden.Equals(ordenActual)) { viewModel.materiales = materiales.OrderByDescending(m => m.MATKL_ID).ToPagedList(pageIndex, viewModel.numRegistros); } else { viewModel.materiales = materiales.OrderBy(m => m.MATKL_ID).ToPagedList(pageIndex, viewModel.numRegistros); } break; case "MATERIAL_GROUP": if (colOrden.Equals(ordenActual)) { viewModel.materiales = materiales.OrderByDescending(m => m.MATERIAL_GROUP).ToPagedList(pageIndex, viewModel.numRegistros); } else { viewModel.materiales = materiales.OrderBy(m => m.MATERIAL_GROUP).ToPagedList(pageIndex, viewModel.numRegistros); } break; default: viewModel.materiales = materiales.OrderBy(m => m.MATERIAL_ID).ToPagedList(pageIndex, viewModel.numRegistros); break; } }
public async Task <IActionResult> Index(MaterialViewModel materialViewModel) { try { var lista = new List <Material>(); if (string.IsNullOrEmpty(materialViewModel.CodigoIngeso) && string.IsNullOrEmpty(materialViewModel.Identificador)) { lista = await db.Material.Select(x => new Material { MaterialId = x.MaterialId, Identificador = x.Identificador, CodigoIngreso = x.CodigoIngreso, StockDisponible = x.StockDisponible, UnidadMedida = x.UnidadMedida, Proveedor = new Proveedor { NombreProveedor = x.Proveedor.NombreProveedor }, TipoNorma = new TipoNorma { Sae = x.TipoNorma.Sae, TipoNormaId = x.TipoNorma.TipoNormaId, DescripcionNorma = x.TipoNorma.DescripcionNorma }, Pais = new Pais { DescripcionPais = x.Pais.DescripcionPais }, MaterialEspecificacion = x.MaterialEspecificacion, Aprobado = x.Aprobado, }).ToListAsync(); materialViewModel.ListaMaretial = lista; return(View(materialViewModel)); } if (string.IsNullOrEmpty(materialViewModel.CodigoIngeso) && !string.IsNullOrEmpty(materialViewModel.Identificador)) { lista = await db.Material.Where(x => x.Identificador.Contains(materialViewModel.Identificador)).Select(x => new Material { MaterialId = x.MaterialId, Identificador = x.Identificador, CodigoIngreso = x.CodigoIngreso, StockDisponible = x.StockDisponible, UnidadMedida = x.UnidadMedida, Proveedor = new Proveedor { NombreProveedor = x.Proveedor.NombreProveedor }, TipoNorma = new TipoNorma { Sae = x.TipoNorma.Sae, TipoNormaId = x.TipoNorma.TipoNormaId, DescripcionNorma = x.TipoNorma.DescripcionNorma }, Pais = new Pais { DescripcionPais = x.Pais.DescripcionPais }, Aprobado = x.Aprobado, MaterialEspecificacion = x.MaterialEspecificacion, }).ToListAsync(); materialViewModel.ListaMaretial = lista; return(View(materialViewModel)); } if (!string.IsNullOrEmpty(materialViewModel.CodigoIngeso) && !string.IsNullOrEmpty(materialViewModel.Identificador)) { lista = await db.Material.Where(x => x.CodigoIngreso.Contains(materialViewModel.CodigoIngeso) && x.Identificador.Contains(materialViewModel.Identificador)).Select(x => new Material { MaterialId = x.MaterialId, Identificador = x.Identificador, CodigoIngreso = x.CodigoIngreso, StockDisponible = x.StockDisponible, UnidadMedida = x.UnidadMedida, Proveedor = new Proveedor { NombreProveedor = x.Proveedor.NombreProveedor }, TipoNorma = new TipoNorma { Sae = x.TipoNorma.Sae, TipoNormaId = x.TipoNorma.TipoNormaId, DescripcionNorma = x.TipoNorma.DescripcionNorma }, Pais = new Pais { DescripcionPais = x.Pais.DescripcionPais }, Aprobado = x.Aprobado, MaterialEspecificacion = x.MaterialEspecificacion, }).ToListAsync(); materialViewModel.ListaMaretial = lista; return(View(materialViewModel)); } if (!string.IsNullOrEmpty(materialViewModel.CodigoIngeso) && string.IsNullOrEmpty(materialViewModel.Identificador)) { lista = await db.Material.Where(x => x.CodigoIngreso.Contains(materialViewModel.CodigoIngeso)).Select(x => new Material { MaterialId = x.MaterialId, Identificador = x.Identificador, CodigoIngreso = x.CodigoIngreso, StockDisponible = x.StockDisponible, TipoMaterial = new TipoMaterial { TipoMaterialId = x.TipoMaterialId }, UnidadMedida = x.UnidadMedida, Proveedor = new Proveedor { NombreProveedor = x.Proveedor.NombreProveedor }, TipoNorma = new TipoNorma { Sae = x.TipoNorma.Sae, TipoNormaId = x.TipoNorma.TipoNormaId, DescripcionNorma = x.TipoNorma.DescripcionNorma }, Pais = new Pais { DescripcionPais = x.Pais == null ? " " : x.Pais.DescripcionPais }, MaterialEspecificacion = x.MaterialEspecificacion, Aprobado = x.Aprobado, }).ToListAsync(); materialViewModel.ListaMaretial = lista; return(View(materialViewModel)); } return(View()); } catch (Exception ex) { TempData["Mensaje"] = $"{Mensaje.Error}|{Mensaje.ErrorListado}"; return(View()); } }
public ActionResult Edit(MaterialViewModel Materialvm, HttpPostedFileBase videofile, HttpPostedFileBase videofile1) { Materialvm.MaterialBibliografico1.FOTO = Materialvm.foto; //posible error Materialvm.MaterialBibliografico1.IDLOCALIDAD = Materialvm.idlocalidad; // Materialvm.MaterialBibliografico1.IDSUBCATEGORIA = Materialvm.subcategory; MATERIALBIBLIOGRAFICO mATERIALBIBLIOGRAFICO = new MATERIALBIBLIOGRAFICO(); mATERIALBIBLIOGRAFICO = Materialvm.MaterialBibliografico1; if (mATERIALBIBLIOGRAFICO.IDSUBCATEGORIA == null) { mATERIALBIBLIOGRAFICO.IDSUBCATEGORIA = Materialvm.subcategory; } var id = checkauthor(Materialvm.Autor1); if (id == 0) { db.AUTORs.Add(Materialvm.Autor1); db.SaveChanges(); Materialvm.MaterialBibliografico1.IDAUTOR = (int)Materialvm.Autor1.IDAUTOR; } else { Materialvm.MaterialBibliografico1.IDAUTOR = id; } //Archivo digital DOCUMENTOLOCALIDAD doc = new DOCUMENTOLOCALIDAD(); if (videofile != null) { string filename = Path.GetFileName(videofile.FileName); videofile.SaveAs(Server.MapPath("/Materiales/" + filename)); doc.LOCACIONOURL = "Materiales/" + filename; db.DOCUMENTOLOCALIDADs.Add(doc); db.SaveChanges(); ViewData["Message"] = "Record Saved Succesfully"; } if (doc.LOCACIONOURL != null) { Materialvm.MaterialBibliografico1.IDLOCALIDAD = doc.IDLOCALIDAD; mATERIALBIBLIOGRAFICO.IDLOCALIDAD = Materialvm.MaterialBibliografico1.IDLOCALIDAD; } DOCUMENTOLOCALIDAD doc1 = new DOCUMENTOLOCALIDAD(); if (videofile1 != null) { string filename = Path.GetFileName(videofile1.FileName); videofile1.SaveAs(Server.MapPath("/Imagenes/" + filename)); Materialvm.MaterialBibliografico1.FOTO = "Imagenes/" + filename; mATERIALBIBLIOGRAFICO.FOTO = Materialvm.MaterialBibliografico1.FOTO; //db.DOCUMENTOLOCALIDADs.Add(doc1); //db.SaveChanges(); ViewData["Message"] = "Record Saved Succesfully"; } if (ModelState.IsValid) { db.Entry(mATERIALBIBLIOGRAFICO).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ID = new SelectList(db.AspNetUsers, "Id", "Email", mATERIALBIBLIOGRAFICO.ID); ViewBag.IDAUTOR = new SelectList(db.AUTORs, "IDAUTOR", "NOMBRE", mATERIALBIBLIOGRAFICO.IDAUTOR); ViewBag.IDCATEGORIA = new SelectList(db.CATERGORIAs, "IDCATEGORIA", "ID", mATERIALBIBLIOGRAFICO.IDCATEGORIA); ViewBag.IDLOCALIDAD = new SelectList(db.DOCUMENTOLOCALIDADs, "IDLOCALIDAD", "LOCACIONOURL", mATERIALBIBLIOGRAFICO.IDLOCALIDAD); ViewBag.IDTIPO = new SelectList(db.TIPODOCUMENTOes, "IDTIPO", "TIPODOCUMENTO1", mATERIALBIBLIOGRAFICO.IDTIPO); ViewBag.IDSUBCATEGORIA = new SelectList(db.SUBCATEGORIAs, "IDSUBCATEGORIA", "NOMBRE", mATERIALBIBLIOGRAFICO.IDSUBCATEGORIA); return(View(mATERIALBIBLIOGRAFICO)); }
public ActionResult Edit(decimal id) { MaterialViewModel Materialvm = new MaterialViewModel(); if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } MATERIALBIBLIOGRAFICO mATERIALBIBLIOGRAFICO = db.MATERIALBIBLIOGRAFICOes.Find(id); ViewBag.Biblioteca = new SelectList(db.BIBLIOTECAs, "IDBIBLIOTECA", "NOMBRE"); Materialvm.MaterialBibliografico1 = mATERIALBIBLIOGRAFICO; Materialvm.foto = mATERIALBIBLIOGRAFICO.FOTO;//added if (mATERIALBIBLIOGRAFICO.IDSUBCATEGORIA != null) { Materialvm.subcategory = mATERIALBIBLIOGRAFICO.IDSUBCATEGORIA; } if (mATERIALBIBLIOGRAFICO.IDLOCALIDAD != null) { Materialvm.idlocalidad = (int)mATERIALBIBLIOGRAFICO.IDLOCALIDAD; } if (Materialvm.MaterialBibliografico1.IDAUTOR != null) { AUTOR autor = db.AUTORs.Find(Materialvm.MaterialBibliografico1.IDAUTOR); Materialvm.Autor1 = autor; } ViewBag.CountryList = new SelectList(GetCategoriaList(), "IDCATEGORIA", "IDCATEGORIA"); if (Materialvm.MaterialBibliografico1.IDCATEGORIA != null) { CATERGORIA categoria = db.CATERGORIAs.Find(Materialvm.MaterialBibliografico1.IDCATEGORIA); Materialvm.Categoria1 = categoria; Materialvm.IDCATEGORIA = Materialvm.MaterialBibliografico1.IDCATEGORIA; } if (Materialvm.MaterialBibliografico1.IDLOCALIDAD != null) { DOCUMENTOLOCALIDAD doc = db.DOCUMENTOLOCALIDADs.Find(Materialvm.MaterialBibliografico1.IDLOCALIDAD); Materialvm.DocumentoLocalidad1 = doc; } ViewBag.Tipo = new SelectList(db.TIPODOCUMENTOes, "IDTIPO", "TIPODOCUMENTO1"); //WELL PROBABLY HAVE BUGS CAUSE MANY ATRIBUTES ARE NULL. if (mATERIALBIBLIOGRAFICO == null) { return(HttpNotFound()); } ViewBag.ID = new SelectList(db.AspNetUsers, "Id", "Email", mATERIALBIBLIOGRAFICO.ID); ViewBag.IDAUTOR = new SelectList(db.AUTORs, "IDAUTOR", "NOMBRE", mATERIALBIBLIOGRAFICO.IDAUTOR); ViewBag.IDCATEGORIA = new SelectList(db.CATERGORIAs, "IDCATEGORIA", "ID", mATERIALBIBLIOGRAFICO.IDCATEGORIA); ViewBag.IDLOCALIDAD = new SelectList(db.DOCUMENTOLOCALIDADs, "IDLOCALIDAD", "LOCACIONOURL", mATERIALBIBLIOGRAFICO.IDLOCALIDAD); ViewBag.IDTIPO = new SelectList(db.TIPODOCUMENTOes, "IDTIPO", "TIPODOCUMENTO1", mATERIALBIBLIOGRAFICO.IDTIPO); ViewBag.IDSUBCATEGORIA = new SelectList(db.SUBCATEGORIAs, "IDSUBCATEGORIA", "NOMBRE", mATERIALBIBLIOGRAFICO.IDSUBCATEGORIA); return(View(Materialvm)); }
public ActionResult Create(MaterialViewModel Materialvm, HttpPostedFileBase videofile, HttpPostedFileBase videofile1) { var id = checkauthor(Materialvm.Autor1); if (id == 0) { db.AUTORs.Add(Materialvm.Autor1); db.SaveChanges(); Materialvm.MaterialBibliografico1.IDAUTOR = (int)Materialvm.Autor1.IDAUTOR; } else { Materialvm.MaterialBibliografico1.IDAUTOR = id; } //Materialvm.Relationship_15.IDAUTOR = (int)Materialvm.MaterialBibliografico1.IDAUTOR; //Agregado para insertar en taba relationship 15 //Materialvm.MaterialBibliografico1.IDCATEGORIA = Materialvm.Categoria1.IDCATEGORIA; //Unir el autor agregado al material DOCUMENTOLOCALIDAD doc = new DOCUMENTOLOCALIDAD(); if (videofile != null) { string filename = Path.GetFileName(videofile.FileName); videofile.SaveAs(Server.MapPath("/Materiales/" + filename)); doc.LOCACIONOURL = "Materiales/" + filename; db.DOCUMENTOLOCALIDADs.Add(doc); db.SaveChanges(); ViewData["Message"] = "Record Saved Succesfully"; } if (doc.LOCACIONOURL != null) { Materialvm.MaterialBibliografico1.IDLOCALIDAD = doc.IDLOCALIDAD; } //Carga de imagenes DOCUMENTOLOCALIDAD doc1 = new DOCUMENTOLOCALIDAD(); if (videofile1 != null) { string filename = Path.GetFileName(videofile1.FileName); videofile1.SaveAs(Server.MapPath("/Imagenes/" + filename)); Materialvm.MaterialBibliografico1.FOTO = "Imagenes/" + filename; //db.DOCUMENTOLOCALIDADs.Add(doc1); //db.SaveChanges(); ViewData["Message"] = "Record Saved Succesfully"; } //Guardar material Materialvm.ID = User.Identity.GetUserId(); Materialvm.MaterialBibliografico1.ID = Materialvm.ID; Materialvm.MaterialBibliografico1.IDLOCALIDAD = 1; db.MATERIALBIBLIOGRAFICOes.Add(Materialvm.MaterialBibliografico1); db.SaveChanges(); return(RedirectToAction("Index", new RouteValueDictionary(new { Controller = "MATERIALBIBLIOGRAFICOes", Action = "Index" }))); }