public IActionResult Post([FromForm] CompanyModel company) { try { CompanyAddedViewModel response = new CompanyAddedViewModel { NumberOfCharsInName = company.Name.Length, NumberOfCharsInDescription = company.Description.Length, IsHidden = !company.IsVisible }; var entity = new ItemEntity { Name = company.Name, Description = company.Description, IsVisible = company.IsVisible }; _dbContext.Items.Add(entity); _dbContext.SaveChanges(); //return Ok(response); return(Ok(_dbContext.Items)); } catch (Exception exception) { return(NotFound(exception)); } }
public Dictionary <string, object> Post(CompanyModel company) { var response = new Dictionary <string, object>(); bool succeded = true; try { var viewModel = new CompanyAddedViewModel { NumberOfCharsInName = company.Name.Length, NumberOfCharsInDescription = company.Description.Length, IsHidden = !company.IsVisible }; response.Add("data", viewModel); } catch (Exception exception) { succeded = false; response.Add("errorMsg:", exception.Message); } response.Add("success", succeded); return(response); }
public IActionResult Index(CompanyModel company) { var viewModel = new CompanyAddedViewModel { NumberOfCharsInName = company.Name.Length, NumberOfCharsInDescription = company.Description.Length, IsHidden = !company.IsVisible, }; return(View("CompanyAdded", viewModel)); }
public IActionResult Add(CompanyItemModel item) { // TODO add to database var viewModel = new CompanyAddedViewModel { Id = 1, Name = item.Name, }; //return View("AddConfirmation", viewModel); return(RedirectToAction("AddConfirmation")); }
public IActionResult Post(CompanyModel company) { try { CompanyAddedViewModel response = new CompanyAddedViewModel { NumberOfCharsInName = company.Name.Length, NumberOfCharsInDescription = company.Description.Length, IsHidden = !company.IsVisible }; return(Ok(response)); } catch (Exception exception) { return(NotFound(exception)); } }
public IActionResult Index(CompanyModel company) { var viewModel = new CompanyAddedViewModel { NumberOfCharsInName = company.Name.Length, NumberOfCharsInDescription = company.Name.Length, IsHidden = !company.IsVisible }; var item = new ItemEntity { Name = company.Name, Description = company.Description, IsVisible = company.IsVisible }; _dbContext.Items.Add(item); _dbContext.SaveChanges(); return(View("CompanyAdded", viewModel)); }