Exemplo n.º 1
0
 public HttpResponseMessage Post([FromBody] SamplePostInputModel input)
 {
     try
     {
         _sampleService.CreateSample(input.UserId, input.StatusId, input.Barcode);
         return(new HttpResponseMessage(HttpStatusCode.OK));
     }
     catch (Exception exception)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exception));
     }
 }
        public ActionResult Create(SampleCreateModel model)
        {
            if (ModelState.IsValid)
            {
                ViewBag.Success = _sampleService.CreateSample((int)model.UserId, (int)model.StatusId, model.Barcode);

                if (ViewBag.Success == true)
                {
                    ViewBag.Message = "New Sample Created";
                    return(View("Index"));
                }
                else
                {
                    ViewBag.Message = "New Sample Creation Failed";
                }
            }

            ViewBag.UsersList  = new SelectList(_userService.GetUsersList(), "Key", "Value");
            ViewBag.StatusList = new SelectList(_statusService.GetStatusList(), "Key", "Value");
            return(View("Create", model));
        }