예제 #1
0
        public async Task <IActionResult> PutPatient(UpdatePatient patient)
        {
            var savedPatient = Utils.GetPatient(_caller, _appDbContext);

            savedPatient.Name    = patient.Name;
            savedPatient.Surname = patient.Surname;
            savedPatient.Address = patient.Address;
            savedPatient.Phone   = patient.Phone;

            _appDbContext.Entry(savedPatient).State = EntityState.Modified;

            await _appDbContext.SaveChangesAsync();

            return(NoContent());
        }
예제 #2
0
        public async Task <IActionResult> PutDocument(int id, Document document)
        {
            if (id != document.DocumentId)
            {
                return(BadRequest());
            }

            _context.Entry(document).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DocumentExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
예제 #3
0
        public async Task <IActionResult> PutHospital(int id, Hospital hospital)
        {
            if (id != hospital.HospitalId)
            {
                return(BadRequest());
            }

            _context.Entry(hospital).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!HospitalExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
예제 #4
0
        public async Task <IActionResult> PutProcedure(int id, Procedure procedure)
        {
            if (id != procedure.ProcedureId)
            {
                return(BadRequest());
            }

            _context.Entry(procedure).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ProcedureExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
예제 #5
0
        public ActionResult <IEnumerable <PatientReceptionViewModel> > GetPatientsReceptions()
        {
            var patient = Utils.GetPatient(_caller, _context);

            var result =
                from reception in _context.Receptions
                join doctor in _context.Doctors on reception.DoctorId equals doctor.DoctorId
                where reception.PatientId == patient.PatientId
                orderby reception.Date
                select new PatientReceptionViewModel
            {
                ReceptionId  = reception.ReceptionId,
                PatientId    = reception.PatientId,
                DoctorId     = reception.DoctorId,
                HospitalId   = reception.HospitalId,
                Time         = reception.Time,
                Duration     = reception.Duration,
                FormatedDate = $"{reception.Date.Day}/{reception.Date.Month}/{reception.Date.Year}",
                DayOfWeek    = reception.DayOfWeek,
                Address      = reception.Address,
                Purpose      = reception.Purpose,
                Result       = reception.Result,
                Price        = reception.Price,
                Name         = doctor.Name,
                PaymentId    = reception.PaymentId,
                IsPayed      = reception.IsPayed
            };

            var receptions = result.ToList();

            for (var i = 0; i < receptions.Count; i++)
            {
                var paymentId   = Guid.NewGuid().ToString();
                var liqPayModel = LiqPayHelper.GetLiqPayModel(paymentId, Convert.ToInt32(receptions[i].Price));
                receptions[i].Data      = liqPayModel.Data;
                receptions[i].Signature = liqPayModel.Signature;

                var receptionToUpdate = _context.Receptions.Find(receptions[i].ReceptionId);
                receptionToUpdate.PaymentId             = paymentId;
                _context.Entry(receptionToUpdate).State = EntityState.Modified;
            }

            _context.SaveChangesAsync();

            return(Ok(receptions));
        }