Esempio n. 1
0
        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));
        }
Esempio n. 2
0
        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));
        }
Esempio n. 3
0
        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));
        }
Esempio n. 4
0
        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"));
        }
Esempio n. 5
0
 public EditResourcesPage()
 {
     InitializeComponent();
     BindingContext = viewModel = new EditResourcesViewModel();
 }