public async Task <PrimaryDciloscode> AddPrimaryDCILOSCode(PrimaryDciloscode ilosCode)
        {
            var result = await _context.PrimaryDciloscodes.AddAsync(ilosCode);

            await _context.SaveChangesAsync();

            return(result.Entity);
        }
        public async Task <PrimaryDciloscode> UpdatePrimaryDCILOSCode(PrimaryDciloscode ilosCode)
        {
            var result = await _context.PrimaryDciloscodes.FirstOrDefaultAsync(s => s.Id == ilosCode.Id);

            if (result != null)
            {
                result.PrimaryCode = ilosCode.PrimaryCode;
                result.Sapplant    = ilosCode.Sapplant;
                await _context.SaveChangesAsync();

                return(result);
            }

            return(null);
        }
示例#3
0
        public async Task <ActionResult <PrimaryDciloscode> > UpdatePrimaryDCILOSCode(int id, PrimaryDciloscode primaryDCILOSCode)
        {
            try
            {
                if (id != primaryDCILOSCode.Id)
                {
                    return(BadRequest());
                }

                var primaryDCILOSCodeToUpdate = await _primaryDCILOSCodeRepository.GetPrimaryDCILOSCode(id);

                if (primaryDCILOSCodeToUpdate == null)
                {
                    return(NotFound($"PrimaryDciloscode with id = {id} not found"));
                }

                return(await _primaryDCILOSCodeRepository.UpdatePrimaryDCILOSCode(primaryDCILOSCode));
            }
            catch (Exception)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, "Error retrieving data from the database."));
            }
        }
示例#4
0
        public async Task <ActionResult <PrimaryDciloscode> > CreatePrimaryDCILOSCode(PrimaryDciloscode primaryDCILOSCode)
        {
            try
            {
                if (primaryDCILOSCode == null)
                {
                    return(BadRequest());
                }

                var createdPrimaryDCILOSCode = await _primaryDCILOSCodeRepository.AddPrimaryDCILOSCode(primaryDCILOSCode);

                return(createdPrimaryDCILOSCode);
            }
            catch (Exception)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, "Error retrieving data from the database."));
            }
        }
 public async void UpdatePrimaryDCILOSCode(int id, PrimaryDciloscode code)
 {
     await httpClient.PutAsJsonAsync($"/api/PrimaryDciloscodes/{id}", code);
 }
        public async Task <PrimaryDciloscode> CreatePrimaryDCILOSCode(PrimaryDciloscode code)
        {
            var result = await httpClient.PostAsJsonAsync("/api/PrimaryDciloscodes", code);

            return(await result.Content.ReadAsAsync <PrimaryDciloscode>());
        }