public void Add_Given_Two_Numbers_When_Add_Then_Return_Correct_Result_Example_With_Normal_Assertion() { // Arrange // Act var result = sut.Add(1, 2); // Assert Assert.AreEqual(3, result); }
public IActionResult Add(Operation operation, string fileName) { var result = _operationService.Add(operation, fileName); if (result != null) { return(Ok(result)); } return(BadRequest(result.Message)); }
public IActionResult Add(OperationClaim operation) { var result = _operationService.Add(operation); if (result.Success) { return(Ok(result)); } return(BadRequest(result)); }
public async Task <IActionResult> Post([FromBody] OperationViewModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var op = Mapper.Map <OperationModel>(model); await _operationService.Add(op); return(new OkObjectResult(new { message = "Operation has been created" })); }
public ActionResult Create(OperationViewModel model) { try { if (ModelState.IsValid) { var entity = model.ToEntity(); _operationService.Add(entity); } return(RedirectToAction("Index")); } catch { return(View()); } }
/// <summary> /// Post请求处理 /// </summary> /// <param name="operationDto"></param> /// <param name="saveState"></param> /// <returns></returns> public void HttpPostSave(OperationDto operationDto, SaveState saveState) { switch (saveState.OperationState) { case OperationState.Add: _operationService.Add(operationDto); break; case OperationState.Update: _operationService.Update(operationDto); break; default: break; } }
public ActionResult CreateOperation(T_Operation model) { if (ModelState.IsValid) { var count = operationService.Add(model); if (count > 0) { return(JsonSuccess(model)); } else { return(JsonError("添加失败")); } } return(JsonError("模型验证失败")); }
public async Task <ActionResult <OperationDto> > Sum(AditionDto sumDto) { if (sumDto.Addends.Count < 2) { return(BadRequest(new { Message = "At least 2 parameters must be specified for this operation." })); } try { Operation operation = await operationService.Add(sumDto.OperationId, sumDto.Addends); return(Ok(OperationMapper.Map(operation))); } catch (Exception ex) { logger.Error(ex, ex.Message); return(Problem("There was a problem processing your request", statusCode: (int?)HttpStatusCode.InternalServerError)); } }
public ContentResult CreateOperation(OperationTransfer operationTransfer) { var operation = new Operation(); operation.CurrentTypeOperation = new TypeOperation() { Id = operationTransfer.CurrentTypeOperation.Id }; operation.TreatmentId = operationTransfer.TreatmentId; if (operationTransfer.Medicines.Any()) { operation.Medicines = new List <Medicine>(); foreach (var id in operationTransfer.Medicines) { var medicine = medicineService.GetItemById(id); operation.Medicines.Add(medicine); } } operationService.Add(operation); operationService.Save(); return(Content("<p>The operation was created successfully!</p>")); }