public IActionResult Create(EditResourcesViewModel model) { if (ModelState.IsValid) { //try //{ Resource resource = new Resource { CultureID = model.CultureId, Key = model.Key, Value = model.Value, ResourceType = model.ResourceType, AddedDate = DateTime.UtcNow, ModifiedDate = DateTime.UtcNow }; _repoResource.Insert(resource); //TempData["UserMessage"] = new { CssClassName = "alert-sucess", Title = "Success!", Message = "Operation Done." }; //return RedirectToAction("Index"); //} //catch (Exception e) //{ // //TempData["UserMessage"] = new { CssClassName = "alert-error", Title = "Error!", Message = "Operation Failed." }; // return RedirectToAction("Error"); //} } return(View(model)); }
public IActionResult Edit(long id) { if (id == null) { return(NotFound()); } EditResourcesViewModel model = new EditResourcesViewModel(); model.Cultures = _repoCulture.GetAll().Select(a => new SelectListItem { Text = $"{a.Name}", Value = a.Id.ToString() }).ToList(); Resource resource = _repoResource.Get(id); if (resource != null) { model.Key = resource.Key; model.Value = resource.Value; model.ResourceType = resource.ResourceType; model.CultureId = resource.CultureID; } return(View(model)); }
public IActionResult Create() { EditResourcesViewModel model = new EditResourcesViewModel(); model.Cultures = _repoCulture.GetAll().Select(a => new SelectListItem { Text = $"{a.Name}", Value = a.Id.ToString() }).ToList(); return(View(model)); }
public IActionResult Edit(long id, EditResourcesViewModel model) { Resource resource = _repoResource.Get(id); if (resource != null) { resource.Key = model.Key; resource.Value = model.Value; resource.ResourceType = model.ResourceType; resource.CultureID = model.CultureId; resource.ModifiedDate = DateTime.UtcNow; _repoResource.Update(resource); } return(RedirectToAction("Index")); }
public EditResourcesPage() { InitializeComponent(); BindingContext = viewModel = new EditResourcesViewModel(); }