Ejemplo n.º 1
0
        public async Task <OperationResult> Edit(CultivaPina.EntityFramework.Models.Sector sector)
        {
            var foundresult = await this.SectorRepository.FindAsync(sector.SectorId);

            if (foundresult == null)
            {
                return(new OperationResult(new[] { $"El {sector.SectorId} no existe." }));
            }

            foundresult.SectorNombre = sector.SectorNombre;


            this.SectorRepository.Update(foundresult);
            await this.SectorRepository.SaveChangesAsync();

            return(new OperationResult(true));
        }
Ejemplo n.º 2
0
        public async Task <OperationResult> CreateAsync(CultivaPina.EntityFramework.Models.Sector sector)
        {
            if (sector == null)
            {
                throw new ArgumentNullException(nameof(sector));
            }

            if (await this.SectorRepository.FirstOrDefaultAsync(f => f.SectorId == sector.SectorId) == null)
            {
                this.SectorRepository.Create(sector);
                await this.SectorRepository.SaveChangesAsync();

                return(new OperationResult(true));
            }

            return(new OperationResult(new[] { $"Código {sector.SectorId} ya existe." }));
        }