예제 #1
0
        public async Task <IActionResult> PutDoctor(int id, Doctor doctor)
        {
            if (id != doctor.DoctorId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
예제 #2
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());
        }
예제 #3
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));
        }
예제 #4
0
        public async Task <IActionResult> Post([FromBody] RegistrationViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var userIdentity = _mapper.Map <AppUser>(model);

            var result = await _userManager.CreateAsync(userIdentity, model.Password);

            if (!result.Succeeded)
            {
                return(new BadRequestObjectResult(Errors.AddErrorsToModelState(result, ModelState)));
            }

            await _appDbContext.Patients.AddAsync(new Patient { IdentityId = userIdentity.Id });

            await _appDbContext.SaveChangesAsync();

            return(new OkObjectResult("Account created"));
        }