public async Task <HttpResponseMessage> Add(VehicleModelView vehicleModelView) { try { if (vehicleModelView.Name == null || vehicleModelView.Abrv == null || vehicleModelView.VehicleMakeId == null) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Model is not complete. Please provide name, abrv and make id")); } var fMakerExist = await MakeService.Read(vehicleModelView.VehicleMakeId); if (fMakerExist == null) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Invalid VehicleMakeId")); } vehicleModelView.VehicleModelId = Guid.NewGuid(); var response = await ModelService.Add(AutoMapper.Mapper.Map <VehicleModelDomain>(vehicleModelView)); return(Request.CreateResponse(HttpStatusCode.OK, response)); } catch { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Couldn't add model. Database error.")); } }
public IActionResult Add([FromBody] AddModel model) { var mappedModel = _mapper.Map <Model>(model); var response = _service.Add(mappedModel); return(Ok(response)); }
public IActionResult AddModel(Model model) { var result = _modelService.Add(model); if (result.Success) { return(Ok(result)); } return(BadRequest(result.Message)); }
public IActionResult Add(Model model) { var result = _modelService.Add(model); if (!result.IsSuccees) { return(BadRequest(result)); } return(Ok(result)); }
public async Task <ActionResult <ModelViewModel> > Add(ModelViewModel modelViewModel) { if (!ModelState.IsValid) { return(FormattedResponse(ModelState)); } await _modelService.Add(_mapper.Map <Model>(modelViewModel)); return(FormattedResponse(modelViewModel)); }
public async Task <IActionResult> Create([FromForm] ModelDTO model) { userDTO = new UserDTO { Name = User.Identity.Name }; if (service.Add(model, userDTO) != null) { return(RedirectToAction("Index")); } return(RedirectToAction("Index", "Home")); }
public async Task <IActionResult> Post([FromBody] Model model) { if (model.Id != 0 || !ModelState.IsValid) { return(BadRequest()); } var createTask = _modelService.Add(model); await createTask; return(createTask.IsCompletedSuccessfully ? Ok() : StatusCode((int)HttpStatusCode.InternalServerError)); }
private bool CheckDetails(TOPModel topModel) { var company = _companyService.Add(CreateCompany(topModel.Company)); var address = _addressService.Add(CreateAddress(topModel.Address)); var teacher = _teacherService.Add(CreateTeacher(topModel.Teacher)); var vocationalQualificationUnit = _vocationalQualificationUnitService.Add( CreateVocationalQualificationUnit(topModel.VocationalQualificationUnit)); if (company == null || address == null || teacher == null || vocationalQualificationUnit == null) { return(false); } return(true); }
/// <summary> /// Post请求 /// </summary> /// <param name="modelDto"></param> /// <param name="saveState"></param> /// <param name="array"></param> public void HttpPostSave(ModelDto modelDto, SaveState saveState, int[] array) { modelDto.Description = modelDto.Description.Trim(); switch (saveState.OperationState) { case OperationState.Add: _modelService.Add(modelDto, array); break; case OperationState.Update: _modelService.Update(modelDto, array); break; default: break; } }
public VocationalQualificationUnit AddVocationalQualificationUnit(VocationalQualificationUnit vocationalQualificationUnit) { return(_vocationalQualificationUnitService.Add(vocationalQualificationUnit)); }
public Teacher AddTeacher(Teacher teacher) { return(_teacherService.Add(teacher)); }