public HomeController(ITestService test) { if (test.Add(1, 1) != 2) { throw new Exception(); } }
public IHttpActionResult Add(Account account) { if (_TestService.Add(account)) { return(Ok()); } return(BadRequest("Unable to update record")); //account.Save(); }
public ActionResult Create() { _testService.Add(new Test() { }); _testService.Save(); return(View()); }
public ActionResult Create([Bind(Include = "ID,Year,Term")] Test test) { if (ModelState.IsValid) { testService.Add(test); return(RedirectToAction("Index")); } return(View(test)); }
public ActionResult Create(TestViewModel test) { if (!ModelState.IsValid) { return(View(test)); } _service.Add(test.MapTo <Test>()); return(RedirectToAction("Index")); }
public async Task <IActionResult> Create([Bind("Id,Title,Description,")] TestModel testModel, IFormFile img) { if (ModelState.IsValid) { _testService.Add(testModel, img); return(RedirectToAction(nameof(Index))); } return(View(testModel)); }
// [AddHeader(ContentType=MimeTypes.Json)] public Stream Post(ConverterRequest request) { base.Response.AddHeader("Content-Disposition", $"attachment; filename=\"{request.File}\";"); using (var zipUtils = new ZipUtils()) { zipUtils.UnzipInput(_testService.GetStream(Request)); zipUtils.ZipOutput(); var w = _testService.Add(2, 3); return(zipUtils.GetResult()); } }
//[Authorize(Roles = "Admin, Editor")] public IHttpActionResult CreateTest([FromBody] NewTestBindingModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } TestDTO newTest = new TestDTO() { Title = model.Title, CategoryId = model.CategoryId, Descr = model.Descr, DurationMin = model.DurationMin, Questions = _mapper.Map <List <QuestionDTO> >(model.Questions) }; _testService.Add(newTest); return(Ok(newTest)); }
public IActionResult CreateTest(Test model) { try { if (ModelState.IsValid) { _testService.Add(model); ViewBag.Msg = "Success"; } else { ViewBag.Error = "Something went wrong"; } } catch { ViewBag.Error = "Something went wrong"; } return(View()); }
public ActionResult Add([FromBody] TestTable testTable) { try { _testService.Add(testTable); return(CreatedAtAction("Get", new { id = testTable.Testid }, testTable)); } catch (Exception ex) { if (ex is ItemNotFoundException) { return(NotFound()); } else if (ex is InvalidInputException) { return(BadRequest()); } return(StatusCode(500)); } }
public async Task <IActionResult> CreateTest([FromBody] TestView model) { if (ModelState.IsValid) { var UserId = _userManager.GetUserId(User); var test = new TEST { ID_USER = UserId, NAME_TEST = model.T.NAME_TEST, RESULT = model.T.RESULT, QUESTION = model.T.QUESTION, ID_TYPE = model.T.ID_TYPE }; await testService.Add(test); return(Ok(test)); } return(BadRequest(ModelState)); }
static void Main(string[] args) { string baseAddress = "http://" + Environment.MachineName + ":8000/Service"; ServiceHost host = new ServiceHost(typeof(Service), new Uri(baseAddress)); host.AddServiceEndpoint(typeof(ITestService), new BasicHttpBinding(), "soap"); WebHttpBinding webBinding = new WebHttpBinding(); webBinding.ContentTypeMapper = new MyRawMapper(); host.AddServiceEndpoint(typeof(ITestService), webBinding, "json").Behaviors.Add(new NewtonsoftJsonBehavior()); Console.WriteLine("Opening the host"); host.Open(); ChannelFactory <ITestService> factory = new ChannelFactory <ITestService>(new BasicHttpBinding(), new EndpointAddress(baseAddress + "/soap")); ITestService proxy = factory.CreateChannel(); Console.WriteLine(proxy.GetPerson()); SendRequest(baseAddress + "/json/GetPerson", "GET", null, null); SendRequest(baseAddress + "/json/EchoPet", "POST", "application/json", "{\"Name\":\"Fido\",\"Color\":\"Black and white\",\"Markings\":\"None\",\"Id\":1}"); SendRequest(baseAddress + "/json/Add", "POST", "application/json", "{\"x\":111,\"z\":null,\"w\":[1,2],\"v\":{\"a\":1},\"y\":222}"); Console.WriteLine("Now using the client formatter"); ChannelFactory <ITestService> newFactory = new ChannelFactory <ITestService>(webBinding, new EndpointAddress(baseAddress + "/json")); newFactory.Endpoint.Behaviors.Add(new NewtonsoftJsonBehavior()); ITestService newProxy = newFactory.CreateChannel(); Console.WriteLine(newProxy.Add(444, 555)); Console.WriteLine(newProxy.EchoPet(new Pet { Color = "gold", Id = 2, Markings = "Collie", Name = "Lassie" })); Console.WriteLine(newProxy.GetPerson()); Console.WriteLine("Press ENTER to close"); Console.ReadLine(); host.Close(); Console.WriteLine("Host closed"); }
public int AddTwoNumber(int a, int b) => _testService.Add(a, b);
public async Task <ActionResult <Test> > PostTest(TestRequest createRequestTest) { var test = await _testService.Add(createRequestTest); return(Ok(test)); }
public void Test() { _testService.Add(new TestDtoInput { UserId = Guid.NewGuid().ToString("N"), Name = "test" }); }
public IHttpActionResult Add([FromBody] Test test) { testService.Add(test); return(Ok()); }