Пример #1
0
        public async Task <IActionResult> UpdatePrescriptionDetails(int id, [FromBody] PrescriptionDetailsUpdateDTO prescriptionDetailsUpdateDTO)
        {
            if (prescriptionDetailsUpdateDTO.Statusid < 0)
            {
                return(BadRequest());
            }
            if (id != prescriptionDetailsUpdateDTO.Id)
            {
                return(BadRequest());
            }

            if (_pharmacyManagementRepository.PrescriptionDetailsExist(prescriptionDetailsUpdateDTO.Id) != true)
            {
                return(NotFound());
            }
            else
            {
                var update = await _pharmacyManagementRepository.UpdatePrescriptionDetails(prescriptionDetailsUpdateDTO);

                if (update == true)
                {
                    return(NoContent());
                }
                else
                {
                    return(NotFound());
                }
            }
        }
        public async Task <bool> UpdatePrescriptionDetails(PrescriptionDetailsUpdateDTO prescriptionDetailsUpdateDTO)
        {
            var details = await _context.ConsultationPrescriptionDetails.FindAsync(prescriptionDetailsUpdateDTO.Id);

            details.Statusid       = prescriptionDetailsUpdateDTO.Statusid;
            details.Lastchangeby   = prescriptionDetailsUpdateDTO.Lastchangeby;
            details.Lastchangedate = DateTime.Now;
            try
            { var update = await _context.SaveChangesAsync();

              if (update >= 1)
              {
                  return(true);
              }
              else
              {
                  return(false);
              } }
            catch (DbUpdateConcurrencyException) when(!PrescriptionDetailsExist(prescriptionDetailsUpdateDTO.Id))
            {
                return(false);
            }
        }