public HttpResponseMessage AddProcedure(int visitId, int procedureId) { try { var visit = m_repository.Entities.Include(x => x.Procedures).FirstOrDefault(x => x.Id == visitId); if (visit == null) { throw new EntityNotFoundException(); } if (visit.IsClosed) { throw new EntityIsClosedException(); } visit.Procedures.Add(procedure_repository.GetById(procedureId)); m_repository.Update(visit); return(new HttpResponseMessage(HttpStatusCode.OK)); } catch (EntityNotFoundException exp) { return(ResponseCreator.GenerateResponse(HttpStatusCode.NotFound, exp)); } catch (EntityIsClosedException exp) { return(ResponseCreator.GenerateResponse(HttpStatusCode.Forbidden, exp)); } }
public HttpResponseMessage Finish(int orderId) { try { var tech_id = System.Web.HttpContext.Current.User.Identity.GetUserId <int>(); var tech = technican_repository.Entities.First(x => x.ApplicationUserId == tech_id); var order = m_repository.GetById(orderId); if (order == null) { throw new EntityNotFoundException(); } order.IsFinished = true; order.DentalTechnican = tech; order.FinishDate = DateTime.Now; m_repository.Update(order); return(new HttpResponseMessage(HttpStatusCode.OK)); } catch (EntityNotFoundException exp) { return(ResponseCreator.GenerateResponse(HttpStatusCode.NotFound, exp)); } catch (Exception exp) { return(ResponseCreator.GenerateResponse(HttpStatusCode.InternalServerError, exp)); } }
public HttpResponseMessage Post([FromBody] PatientBindingModel value) { try { Patient patient = m_repository.GetById(value.Id); patient.IsMen = value.IsMen; patient.MedicalCardNumber = value.MedicalCardNumber; patient.PersonInfo.Name = value.Name; patient.PersonInfo.Surname = value.Surname; patient.PersonInfo.Middlename = value.Middlename; return(new HttpResponseMessage(HttpStatusCode.OK)); } catch (EntityAlreadyExistsException exp) { return(ResponseCreator.GenerateResponse(HttpStatusCode.BadRequest, exp)); //new HttpResponseMessage(HttpStatusCode.BadRequest); } catch (EntityNotFoundException exp) { return(ResponseCreator.GenerateResponse(HttpStatusCode.NotFound, exp)); //new HttpResponseMessage(HttpStatusCode.BadRequest); } catch (Exception exp) { return(ResponseCreator.GenerateResponse(HttpStatusCode.InternalServerError, exp));//new HttpResponseMessage(HttpStatusCode.InternalServerError); } }
public override HttpResponseMessage Post([FromBody] Order value) { try { if (value.IsClosed) { throw new EntityIsClosedException(); } //value.IsFinished = false; var doctor = get_current_doctor(); if (doctor == null) { throw new EntityNotFoundException(); } value.Doctor = doctor; return(base.Post(value)); } catch (EntityIsClosedException exp) { return(ResponseCreator.GenerateResponse(HttpStatusCode.Forbidden, exp)); } }
public HttpResponseMessage AddTooth(int orderId, int toothNo, int procedureId) { try { var order = m_repository.GetById(orderId); if (order == null) { throw new EntityNotFoundException(); } if (order.IsClosed) { throw new EntityIsClosedException(); } order.Teeth.Add(new ToothWork() { ToothNo = toothNo, ProcedureId = procedureId }); m_repository.Update(order); return(new HttpResponseMessage(HttpStatusCode.OK)); } catch (EntityNotFoundException exp) { return(ResponseCreator.GenerateResponse(HttpStatusCode.NotFound, exp)); } catch (EntityIsClosedException exp) { return(ResponseCreator.GenerateResponse(HttpStatusCode.Forbidden, exp)); } }
public HttpResponseMessage Post(BaseBindingModel value) { try { DentalTechnican technican = m_repository.GetById(value.Id); technican.PersonInfo.Name = value.Name; technican.PersonInfo.Surname = value.Surname; technican.PersonInfo.Middlename = value.Middlename; m_repository.Update(technican); return(new HttpResponseMessage(HttpStatusCode.OK)); } catch (EntityAlreadyExistsException exp) { return(ResponseCreator.GenerateResponse(HttpStatusCode.BadRequest, exp)); } catch (EntityNotFoundException exp) { return(ResponseCreator.GenerateResponse(HttpStatusCode.NotFound, exp)); } catch (Exception exp) { return(ResponseCreator.GenerateResponse(HttpStatusCode.InternalServerError, exp)); } }
public HttpResponseMessage Post(DoctorBindingModel value) { try { Doctor doctor = m_repository.GetById(value.Id); doctor.Image = value.Image; doctor.Text = value.Text; doctor.PersonInfo.Name = value.Name; doctor.PersonInfo.Surname = value.Surname; doctor.PersonInfo.Middlename = value.Middlename; m_repository.Update(doctor); return(new HttpResponseMessage(HttpStatusCode.OK)); } catch (EntityAlreadyExistsException exp) { return(ResponseCreator.GenerateResponse(HttpStatusCode.BadRequest, exp)); } catch (EntityNotFoundException exp) { return(ResponseCreator.GenerateResponse(HttpStatusCode.NotFound, exp)); } catch (Exception exp) { return(ResponseCreator.GenerateResponse(HttpStatusCode.InternalServerError, exp)); } }
public HttpResponseMessage Post([FromBody] ClinicInfo value) { try { m_repository.Update(value); return(new HttpResponseMessage(HttpStatusCode.OK)); } catch (EntityNotFoundException exp) { return(ResponseCreator.GenerateResponse(HttpStatusCode.NotFound, exp)); //new HttpResponseMessage(HttpStatusCode.NotFound); } catch (Exception exp) { return(ResponseCreator.GenerateResponse(HttpStatusCode.InternalServerError, exp)); //new HttpResponseMessage(HttpStatusCode.InternalServerError); } }
//Удалить virtual public HttpResponseMessage Delete(int id) { try { m_repository.Delete(id); return(new HttpResponseMessage(HttpStatusCode.OK)); } catch (EntityNotFoundException exp) { return(ResponseCreator.GenerateResponse(HttpStatusCode.NotFound, exp.Message));//new HttpResponseMessage(HttpStatusCode.NotFound); } catch (Exception exp) { return(ResponseCreator.GenerateResponse(HttpStatusCode.InternalServerError, exp.Message)); //new HttpResponseMessage(HttpStatusCode.InternalServerError); } }
//Создать virtual public HttpResponseMessage Put([FromBody] M value) { try { int id = m_repository.Create(value); //JObject obj = new JObject(); //obj["id"] = id; return(Request.CreateResponse <PutResponse>(HttpStatusCode.OK, new PutResponse(id))); } catch (EntityAlreadyExistsException exp) { return(ResponseCreator.GenerateResponse(HttpStatusCode.BadRequest, exp));// new HttpResponseMessage(HttpStatusCode.BadRequest); } catch (Exception exp) { return(ResponseCreator.GenerateResponse(HttpStatusCode.InternalServerError, exp)); //new HttpResponseMessage(HttpStatusCode.InternalServerError); } }
public HttpResponseMessage Close(int visitId) { try { var visit = m_repository.GetById(visitId); if (visit == null) { throw new EntityNotFoundException(); } visit.IsClosed = true; m_repository.Update(visit); return(new HttpResponseMessage(HttpStatusCode.OK)); } catch (EntityNotFoundException exp) { return(ResponseCreator.GenerateResponse(HttpStatusCode.NotFound, exp)); } }
public HttpResponseMessage Put([FromBody] PatientBindingModel value) { try { Patient patient = new Patient() { MedicalCardNumber = value.MedicalCardNumber, IsMen = value.IsMen, DateOfBirth = value.DateOfBirth }; PersonInfo pi = new PersonInfo(value.Surname, value.Name, value.Middlename); patient.PersonInfo = pi; m_repository.Create(patient); return(new HttpResponseMessage(HttpStatusCode.OK)); } catch (EntityAlreadyExistsException exp) { return(ResponseCreator.GenerateResponse(HttpStatusCode.BadRequest, exp)); //new HttpResponseMessage(HttpStatusCode.BadRequest); } catch (Exception exp) { return(ResponseCreator.GenerateResponse(HttpStatusCode.InternalServerError, exp)); //new HttpResponseMessage(HttpStatusCode.InternalServerError); } }
//Удаляет процедуру из посещения public HttpResponseMessage RemoveTooth(int id) { try { /*var order = m_repository.Entities.Include("Teeth.Procedure").Include(x=>x.ClinicInfo).FirstOrDefault(x => x.Id == orderId); * if (order == null) throw new EntityNotFoundException(); * if (order.IsClosed)throw new EntityIsClosedException(); * * var tooth = order.Teeth.FirstOrDefault(x => x.ToothNo == toothNo); * //order.Teeth.Remove(tooth); * //m_repository.Update(order);*/ tooth_repository.Delete(id); return(new HttpResponseMessage(HttpStatusCode.OK)); } catch (EntityNotFoundException exp) { return(ResponseCreator.GenerateResponse(HttpStatusCode.NotFound, exp)); } catch (EntityIsClosedException exp) { return(ResponseCreator.GenerateResponse(HttpStatusCode.Forbidden, exp)); } }
//Создание нового запрещено public override HttpResponseMessage Put([FromBody] DentalTechnican value) { return(ResponseCreator.GenerateResponse(HttpStatusCode.BadRequest, "To register DentalTechnican use \"api/Account/RegisterDentalTechnican\"")); }