Exemplo n.º 1
0
 public HomeController(ITestService test)
 {
     if (test.Add(1, 1) != 2)
     {
         throw new Exception();
     }
 }
 public HomeController(ITestService test)
 {
     if (test.Add(1, 1) != 2)
     {
         throw new Exception();
     }
 }
Exemplo n.º 3
0
 public IHttpActionResult Add(Account account)
 {
     if (_TestService.Add(account))
     {
         return(Ok());
     }
     return(BadRequest("Unable to update record"));
     //account.Save();
 }
Exemplo n.º 4
0
        public ActionResult Create()
        {
            _testService.Add(new Test()
            {
            });
            _testService.Save();

            return(View());
        }
Exemplo n.º 5
0
        public ActionResult Create([Bind(Include = "ID,Year,Term")] Test test)
        {
            if (ModelState.IsValid)
            {
                testService.Add(test);
                return(RedirectToAction("Index"));
            }

            return(View(test));
        }
Exemplo n.º 6
0
        public ActionResult Create(TestViewModel test)
        {
            if (!ModelState.IsValid)
            {
                return(View(test));
            }

            _service.Add(test.MapTo <Test>());
            return(RedirectToAction("Index"));
        }
Exemplo n.º 7
0
        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));
        }
Exemplo n.º 8
0
 // [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());
     }
 }
Exemplo n.º 9
0
        //[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));
        }
Exemplo n.º 10
0
 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));
            }
        }
Exemplo n.º 12
0
        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));
        }
Exemplo n.º 13
0
        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");
        }
Exemplo n.º 14
0
 public int AddTwoNumber(int a, int b) => _testService.Add(a, b);
Exemplo n.º 15
0
        public async Task <ActionResult <Test> > PostTest(TestRequest createRequestTest)
        {
            var test = await _testService.Add(createRequestTest);

            return(Ok(test));
        }
Exemplo n.º 16
0
 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());
 }