public async Task <SectorMaterial> InsertSectorMaterial(String material, String sector) { try { List <SectorMaterial> sm = await this.FindMaterialBySector(sector); foreach (SectorMaterial smaterial in sm) { if (smaterial.Material != material && smaterial.Sector == sector) { SectorMaterial sectorMaterial = new SectorMaterial(); sectorMaterial.Id = await this.LastIdSectorMaterial(); sectorMaterial.Sector = sector; sectorMaterial.Material = material; this.context.SectorMaterial.Add(sectorMaterial); await this.context.SaveChangesAsync(); return(sectorMaterial); } } return(null); } catch (Exception e) { Debug.WriteLine(e.Message); return(null); } }
public async Task <SectorMaterial> UpdatetSectorMaterial(int id, String material, String sector) { try { SectorMaterial sectorMaterial = await this.FindSectorMaterialById(id); sectorMaterial.Material = material; sectorMaterial.Sector = sector; await this.context.SaveChangesAsync(); return(sectorMaterial); } catch (Exception e) { Debug.WriteLine(e.Message); return(null); } }
public async Task <SectorMaterial> UpdatetSectorMaterial(SectorMaterial sectorMaterial) { return(await this.repositoryEssup.UpdatetSectorMaterial(sectorMaterial.Id, sectorMaterial.Material, sectorMaterial.Sector)); }
public async Task <ActionResult <SectorMaterial> > InsertSectorMaterial(SectorMaterial sectorMaterial) { return(await this.repositoryEssup.InsertSectorMaterial(sectorMaterial.Material, sectorMaterial.Sector)); }