Esempio n. 1
0
        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);
            }
        }
Esempio n. 2
0
        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);
            }
        }
Esempio n. 3
0
 public async Task <SectorMaterial> UpdatetSectorMaterial(SectorMaterial sectorMaterial)
 {
     return(await this.repositoryEssup.UpdatetSectorMaterial(sectorMaterial.Id, sectorMaterial.Material, sectorMaterial.Sector));
 }
Esempio n. 4
0
 public async Task <ActionResult <SectorMaterial> > InsertSectorMaterial(SectorMaterial sectorMaterial)
 {
     return(await this.repositoryEssup.InsertSectorMaterial(sectorMaterial.Material, sectorMaterial.Sector));
 }