Ejemplo n.º 1
0
        public async Task <IActionResult> CancelMedicalAppointment([FromRoute] int id)
        {
            if (!ModelState.IsValid)
            {
                return(Json(new { success = false, message = ErrorModelValidation.ShowError(new SerializableError(ModelState).Values) }));
            }

            try
            {
                var entity = LMedicalAppointment.GetMedicalAppointmentById(id, _repository);

                if (entity == null)
                {
                    Json(new { success = false, message = "No se pudo encontrar el registro indicado." });
                }

                LMedicalAppointment.CancelMedicalAppointment(entity, _repository, _IunitOfWork);
                return(Json(new { success = true, message = "Registro cancelado correctamente." }));
            }
            catch (Exception exc)
            {
                string ErrorMsg = exc.GetBaseException().InnerException != null?exc.GetBaseException().InnerException.Message : exc.GetBaseException().Message;

                return(Json(new { success = false, message = "Error!. " + ErrorMsg }));
            }
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> GetMedicalAppointmentsByUser()
        {
            try
            {
                var userId = User.getUserId();
                return(Json(new { success = true, message = LMedicalAppointment.GetMedicalAppointmentsByUser(userId, _repository) }));
            }
            catch (Exception exc)
            {
                string ErrorMsg = exc.GetBaseException().InnerException != null?exc.GetBaseException().InnerException.Message : exc.GetBaseException().Message;

                return(Json(new { success = false, message = "Error!. " + ErrorMsg }));
            }
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> SaveMedicalAppointment([FromBody] MedicalAppointment entity)
        {
            if (!ModelState.IsValid)
            {
                return(Json(new { success = false, message = ErrorModelValidation.ShowError(new SerializableError(ModelState).Values) }));
            }

            try
            {
                entity.UserId = User.getUserId();
                entity.Active = true;
                LMedicalAppointment.SaveMedicalAppointment(entity, _repository, _IunitOfWork);
                return(Json(new { success = true, message = "Registro guardado correctamente." }));
            }
            catch (Exception exc)
            {
                string ErrorMsg = exc.GetBaseException().InnerException != null?exc.GetBaseException().InnerException.Message : exc.GetBaseException().Message;

                return(Json(new { success = false, message = "Error!. " + ErrorMsg }));
            }
        }