public AllMaterial MapAllMaterialVmToAllMaterial(AddMaterialViewModel addvm) { AllMaterial allMaterial = new AllMaterial(); allMaterial.MaterialCode = addvm.MaterialCode; allMaterial.Datetime = new DateTime?(DateTime.Now); if (addvm.MaterialImage != null) { allMaterial.MaterialImagePath = addvm.MaterialImagePath; } else { allMaterial.MaterialImagePath = "No Image"; } allMaterial.MaterialTypeId = new int?(addvm.MaterialId); if (addvm.MaterialId == 3) { allMaterial.Sub_KasabId = new int?(addvm.SubMaterialId); } if (addvm.MaterialId == 5) { allMaterial.Price = new double?((double)addvm.Price); } if (addvm.MaterialId == 6) { allMaterial.Price = new double?((double)addvm.Price); } if (addvm.MaterialId == 7) { allMaterial.Price = new double?((double)addvm.Price); } return allMaterial; }
public AllMaterial MapEditMaterialVmToEditMaterial(EditMaterialViewModel addvm) { AllMaterial allMaterial = new AllMaterial(); allMaterial.MaterialCode = addvm.MaterialCode; allMaterial.Datetime = new DateTime?(DateTime.Now); allMaterial.MaterialId = addvm.MaterialId; if (addvm.MaterialImage != null) { allMaterial.MaterialImagePath = addvm.MaterialImagePath; } return allMaterial; }
public int insertNewMaterial(AllMaterial allmat) { this.db.AllMaterials.Add(allmat); int result; try { this.db.SaveChanges(); result = 1; } catch { result = 0; } return result; }