[HttpPost]//создание дела public async Task <IActionResult> Create([FromBody] Do Do) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.Do.Add(Do); await _context.SaveChangesAsync(); return(CreatedAtAction("GetDo", new { id = Do.DoId }, Do)); }
public async Task <DoctorDto> CreateOrEditDoctor([FromBody] CreateOrEditDoctorDto input) { var doctor = _mapper.Map <Doctors>(input); if (input.Id.HasValue && input.Id.Value != 0) { _doContext.Doctors.Update(doctor); } else { await _doContext.Doctors.AddAsync(doctor); } await _doContext.SaveChangesAsync(); return(_mapper.Map <DoctorDto>(doctor)); }
public async Task <DiseaseKindsDto> CreateOrEditDiseaseKind([FromBody] CreateOrEditDiseaseKindsDto input) { var diseaseKind = _mapper.Map <DiseaseKinds>(input); if (input.Id.HasValue && input.Id.Value != 0) { _doContext.DiseaseKinds.Update(diseaseKind); } else { await _doContext.DiseaseKinds.AddAsync(diseaseKind); } await _doContext.SaveChangesAsync(); return(_mapper.Map <DiseaseKindsDto>(diseaseKind)); }
public async Task <UserDto> CreateOrEditUser(CreateOrEditUserDto input) { var user = _mapper.Map <Users>(input); if (input.Id.HasValue && input.Id.Value != 0) { _doContext.Users.Update(user); } else { await _doContext.Users.AddAsync(user); } await _doContext.SaveChangesAsync(); return(_mapper.Map <UserDto>(user)); }
public async Task <HospitalDto> CreateOrEditHospital([FromBody] CreateOrEditHospitalDto input) { var hospital = _mapper.Map <Hospitals>(input); if (input.Id.HasValue && input.Id.Value != 0) { _doContext.Hospitals.Update(hospital); } else { await _doContext.Hospitals.AddAsync(hospital); } await _doContext.SaveChangesAsync(); return(_mapper.Map <HospitalDto>(hospital)); }
public async Task <NewsKindDto> CreateOrEditNewsKind([FromBody] CreateOrEditNewKindDto input) { var newsKind = _mapper.Map <NewsKinds>(input); if (input.Id.HasValue && input.Id.Value != 0) { _doContext.NewsKinds.Update(newsKind); } else { await _doContext.NewsKinds.AddAsync(newsKind); } await _doContext.SaveChangesAsync(); return(_mapper.Map <NewsKindDto>(newsKind)); }
public async Task <DepartmentDto> CreateOrEditDepartment([FromBody] CreateOrEditDepartmentDto input) { var department = _mapper.Map <Departments>(input); if (input.Id.HasValue && input.Id.Value != 0) { _doContext.Departments.Update(department); } else { await _doContext.Departments.AddAsync(department); } await _doContext.SaveChangesAsync(); return(_mapper.Map <DepartmentDto>(department)); }
public async Task <HealthNewDto> CreateOrEditHealthNew([FromBody] CreateOrEditHealthNewDto input) { var healthNews = _mapper.Map <HealthNews>(input); healthNews.DateTime = DateTime.Now; if (input.Id.HasValue && input.Id.Value != 0) { _doContext.HealthNews.Update(healthNews); } else { await _doContext.HealthNews.AddAsync(healthNews); } await _doContext.SaveChangesAsync(); return(_mapper.Map <HealthNewDto>(healthNews)); }
public async Task <DiseaseKnowledgeDto> CreateOrEditDiseaseKnowledge([FromBody] CreateOrEditDiseaseKnowledgeDto input) { var diseaseKnowledges = _mapper.Map <DiseaseKnowledge>(input); diseaseKnowledges.DateTime = DateTime.Now; if (input.Id.HasValue && input.Id.Value != 0) { _doContext.DiseaseKnowledges.Update(diseaseKnowledges); } else { await _doContext.DiseaseKnowledges.AddAsync(diseaseKnowledges); } await _doContext.SaveChangesAsync(); return(_mapper.Map <DiseaseKnowledgeDto>(diseaseKnowledges)); }
public async Task <ProblemDto> CreateOrEditProblem([FromBody] CreateOrEditProblemDto input) { var problem = _mapper.Map <Problems>(input); if (input.Id.HasValue && input.Id.Value != 0) { _doContext.Problems.Update(problem); } else { problem.CreateTime = DateTime.Now; problem.Status = 0; await _doContext.Problems.AddAsync(problem); } await _doContext.SaveChangesAsync(); return(_mapper.Map <ProblemDto>(problem)); }
public async Task <AnswerDto> CreateOrEditAnswer([FromBody] CreateOrEditAnswerDto input) { var answer = _mapper.Map <Answers>(input); answer.Type = 0; if (input.Id.HasValue && input.Id.Value != 0) { _doContext.Answers.Update(answer); } else { answer.CreateTime = DateTime.Now; await _doContext.Answers.AddAsync(answer); } await _doContext.SaveChangesAsync(); return(_mapper.Map <AnswerDto>(answer)); }