Ejemplo n.º 1
0
        public IActionResult EditDictionary(string dictionary)
        {
            EditDictionaryViewModel editDictionary = new EditDictionaryViewModel();

            switch (dictionary)
            {
            case "teachers":
                editDictionary.dictionaryItem = plannerData.schoolData.teachers;
                break;

            case "rooms":
                editDictionary.dictionaryItem = plannerData.schoolData.rooms;
                break;

            case "classes":
                editDictionary.dictionaryItem = plannerData.schoolData.classes;
                break;

            case "groups":
                editDictionary.dictionaryItem = plannerData.schoolData.groups;
                break;

            default:
                break;
            }

            editDictionary.dictionaryName = dictionary;
            return(View(editDictionary));
        }
 public EditDictionaryView(Dictionary selectedDictionary)
 {
     InitializeComponent();
     this.Title = "Edit Dictionary";
     NavigationPage.SetHasBackButton(this, true);
     editDictionaryViewModel = new EditDictionaryViewModel(this.Navigation, selectedDictionary);
     this.BindingContext     = editDictionaryViewModel;
 }
Ejemplo n.º 3
0
        public ActionResult Edit(int?id)
        {
            if (!id.HasValue)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            string userId = User.Identity.GetUserId();

            var resultWithData = _dictionaryService.GetById(id.Value, userId);

            if (!resultWithData.Success)
            {
                // TODO
            }

            var dictionary = resultWithData.ResultData;

            if (dictionary == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.NotFound));
            }

            var model = new EditDictionaryViewModel
            {
                Id          = dictionary.Id,
                Name        = dictionary.Name,
                OldName     = dictionary.Name,
                Description = dictionary.Description,
            };

            var resultWithDataLanguages = _languageService.GetAll();

            if (!resultWithDataLanguages.Success)
            {
                // TODO
            }

            var languages = resultWithDataLanguages.ResultData;

            ViewBag.SourceLanguageId = new SelectList(languages, "Id", "Name", dictionary.SourceLanguageId);
            ViewBag.TargetLanguageId = new SelectList(languages, "Id", "Name", dictionary.TargetLanguageId);

            return(View("Edit", model));
        }
Ejemplo n.º 4
0
        public async Task <ActionResult> Edit(EditDictionaryViewModel model)
        {
            if (!ModelState.IsValid)
            {
                ViewBag.Result = "Error";
                return(PartialView("_Edit", model));
            }

            var resultWithDataLanguages = _languageService.GetAll();

            if (!resultWithDataLanguages.Success)
            {
                // TODO
            }

            var languages = resultWithDataLanguages.ResultData;

            ViewBag.SourceLanguageId = new SelectList(languages, "Id", "Name", model.SourceLanguageId);
            ViewBag.TargetLanguageId = new SelectList(languages, "Id", "Name", model.TargetLanguageId);

            dynamic dictionary = new ExpandoObject();

            dictionary.Id                = model.Id;
            dictionary.Name              = model.Name;
            dictionary.Description       = model.Description;
            dictionary.ApplicationUserId = User.Identity.GetUserId();
            dictionary.SourceLanguageId  = model.SourceLanguageId;
            dictionary.TargetLanguageId  = model.TargetLanguageId;

            var result = await _dictionaryService.UpdateAsync(dictionary);

            if (!result.Success)
            {
                ViewBag.Result = "Error";
                return(PartialView("_Edit", model));
            }

            ViewBag.Result = "Success";
            return(PartialView("_Edit"));
        }