Beispiel #1
0
        private void SetLanguage(Konsultant newConsultant, LanguageViewModel lang)
        {
            Language current = string.IsNullOrEmpty(lang.Id) ?
                               new Language
            {
                Name = lang.Name
            } :
            _langService.GetById(Guid.Parse(lang.Id));

            if (lang.IsDeleted)
            {
                _langService.Delete(current);
            }
            else
            {
                newConsultant.Languages.Add(
                    new KnownLanguage
                {
                    Language     = current,
                    LanguageId   = current.Id,
                    KonsultantId = newConsultant.Id,
                    IsRelevant   = lang.IsRelevant,
                    Fluency      = (Fluency)Enum.Parse(typeof(Fluency), lang.Fluency.ToString())
                });
            }
        }
 public MenuUserControl()
 {
     InitializeComponent();
     languageWM   = new LanguageViewModel();
     _exExcel     = ExportExcel.Instance;
     _workspaceVM = WorkspaceViewModel.Instance;
 }
Beispiel #3
0
        public IHttpActionResult Post(LanguageViewModel languageViewModel)
        {
            try
            {
                var languageOld = this.languageBLL.GetLanguageByCode(languageViewModel.Code);

                if (languageOld != null && languageOld.Id != Guid.Empty)
                {
                    throw new BusinessException(Messages.ErrorCodeLanguage);
                }

                var result = this.languageBLL.Add(languageViewModel);
                if (result == Guid.Empty)
                {
                    throw new BusinessException(Messages.ErrorAddLanguage);
                }
                var response = Request.CreateResponse(System.Net.HttpStatusCode.OK, Messages.SuccessfulUperationCrud);

                return(this.ResponseMessage(response));
            }
            catch (BusinessException ex)
            {
                var response = Request.CreateResponse(System.Net.HttpStatusCode.InternalServerError, ex.Message);
                return(this.ResponseMessage(response));
            }
            catch (Exception ex)
            {
                var response = Request.CreateResponse(System.Net.HttpStatusCode.InternalServerError, Messages.Generic_Error);
                return(this.ResponseMessage(response));
            }
        }
Beispiel #4
0
        // GET: Languages
        public async Task <ActionResult> Index()
        {
            try
            {
                var results = new LanguagesModel();
                //Call API Provider
                controllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
                var list = await APIProvider.Authorize_Get <List <LanguageViewModel> >(_userSession.BearerToken, controllerName, APIConstant.API_Resource_CMS, ARS.Get);

                var language = new LanguageViewModel();

                results.lstLanguageViewModel = (list != null ? list : new List <LanguageViewModel>());
                results.LanguageViewModel    = language;

                TempData["Data"] = list;
                return(View(results));
            }
            catch (HttpException ex)
            {
                Logger.LogError(ex);
                int statusCode = ex.GetHttpCode();
                if (statusCode == 401)
                {
                    TempData["Alert"] = ApplicationGenerator.RenderResult(FuntionType.Department, APIConstant.ACTION_ACCESS);
                    return(new HttpUnauthorizedResult());
                }

                throw ex;
            }
        }
        public async Task <IActionResult> PutLanguage([FromRoute] int id, [FromBody] LanguageViewModel source)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != source.LanguageId)
            {
                return(BadRequest());
            }

            try
            {
                var language = await _languageRepository.Find(id);

                language.Name     = source.Name;
                language.IsActive = source.IsActive;

                await _languageRepository.Update(language);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!await _languageRepository.Exists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw new ApiException(HttpStatusCode.BadRequest, "some thing went wrong with update!");
                }
            }
            return(NoContent());
        }
Beispiel #6
0
        public ActionResult Create()
        {
            var empty = new LanguageViewModel();
            var data  = empty.ToVM();

            return(View(data));
        }
Beispiel #7
0
        public async Task <ActionResult> Edit(LanguageViewModel model, HttpPostedFileBase fileUpload)
        {
            if (ModelState.IsValid)
            {
                if (fileUpload != null)
                {
                    model.Icon = FileManagement.ImageToByteArray(fileUpload);
                }

                //Call API Provider
                string strUrl = APIProvider.APIGenerator(controllerName, APIConstant.ACTION_UPDATE);
                var    result = await APIProvider.Authorize_DynamicTransaction <LanguageViewModel, bool>(model, _userSession.BearerToken, strUrl, APIConstant.API_Resource_CMS, ARS.IgnoredARS);

                if (result)
                {
                    TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.SUCCESS, ApplicationGenerator.GeneralActionMessage(APIConstant.ACTION_UPDATE, ApplicationGenerator.TypeResult.SUCCESS));
                }
                else
                {
                    TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.FAIL, ApplicationGenerator.GeneralActionMessage(APIConstant.ACTION_UPDATE, ApplicationGenerator.TypeResult.FAIL));
                }
                return(RedirectToAction("Index"));
            }
            else
            {
                TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.FAIL, ApplicationGenerator.GeneralActionMessage(APIConstant.ACTION_UPDATE, ApplicationGenerator.TypeResult.FAIL));
                return(View());
            }
        }
        public async Task <IActionResult> Edit(LanguageViewModel model)
        {
            var header = this.Request.Headers["sec-fetch-site"];

            if (header == "none")
            {
                return(RedirectToAction("Index", "Advertisement"));
            }
            if (ModelState.IsValid)
            {
                Language entity = db.Languages.FirstOrDefault(e => e.Id == model.language.Id);
                entity.LanguageName     = model.language.LanguageName;
                entity.ProfeciencyLevel = model.language.ProfeciencyLevel;
                db.Update <Language>(entity);
                await db.SaveChangesAsync();

                toastNotification.AddSuccessToastMessage("Language Edited !", new NotyOptions
                {
                    Theme   = "metroui",
                    Timeout = 1500,
                    Layout  = "topCenter"
                });
            }
            return(PartialView("_Edit", model));
        }
Beispiel #9
0
        // GET: Language/Delete/5
        public async Task <IActionResult> Delete(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var language = await _context.Language
                           .Include(l => l.User)
                           .SingleOrDefaultAsync(m => m.LanguageId == id);

            if (language == null)
            {
                return(NotFound());
            }

            LanguageViewModel viewModel = new LanguageViewModel
            {
                LanguageId      = language.LanguageId,
                Language1       = language.Language1,
                PrimaryLanguage = language.PrimaryLanguage,
                Proficiency     = language.Proficiency,
                UserId          = _userId,
                User            = language.User
            };

            return(View(viewModel));
        }
Beispiel #10
0
        public LanguageViewModel Update(LanguageViewModel languageViewModel)
        {
            var language = _mapper.Map <LanguageViewModel, Language>(languageViewModel);

            _languageService.Update(language, language.Id);
            return(languageViewModel);
        }
Beispiel #11
0
        public IActionResult Create()
        {
            var header = this.Request.Headers["sec-fetch-site"];

            if (header == "none")
            {
                return(RedirectToAction("Index", "Advertisement"));
            }
            LanguageViewModel model = new LanguageViewModel
            {
                language = new Language(),
                list     = new List <SelectListItem>
                {
                    new SelectListItem {
                        Text = "Native", Value = "Native"
                    },
                    new SelectListItem {
                        Text = "Advanced", Value = "Advanced"
                    },
                    new SelectListItem {
                        Text = "Intermediate", Value = "Intermediate"
                    },
                    new SelectListItem {
                        Text = "Novice", Value = "Novice"
                    }
                }
            };

            return(PartialView("_Create", model));
        }
Beispiel #12
0
        public LanguageViewModel Add(LanguageViewModel languageViewModel)
        {
            var language = _mapper.Map <LanguageViewModel, Language>(languageViewModel);

            _languageService.Add(language);
            return(languageViewModel);
        }
        public async Task <IActionResult> ChangeLanguage(LanguageViewModel model)
        {
            string langId = model?.Language.ToLower();

            if (RecroDict.ValidLanguages.ContainsKey(langId))
            {
                var prev = RecroDict.SetSessionLanguage(this.HttpContext, langId);
                if (prev != langId && RecroSec.IsAuthenticated(this.HttpContext))
                {
                    var userId = RecroSec.GetCurrentUserId(this.HttpContext);
                    if (userId != RecroSec.AnonymousId)
                    {
                        var ctx  = this.RGDbContext.GetContext <IdentityDbContextBase>();
                        var user = ctx.RGFUser.SingleOrDefault(e => e.UserId == userId);
                        if (user != null)
                        {
                            user.Language = langId;
                            await ctx.SaveChangesAsync();
                        }
                    }
                }
            }
            if (string.IsNullOrEmpty(model?.ReturnUrl) || !Url.IsLocalUrl(model.ReturnUrl))
            {
                return(LocalRedirect("/"));
            }
            return(LocalRedirect(model.ReturnUrl));
        }
Beispiel #14
0
        /// <summary>
        /// Displays the start page for the installer (step1).
        /// </summary>
        public ActionResult Step1(string language)
        {
            Thread.CurrentThread.CurrentUICulture = new CultureInfo(language);
            LanguageViewModel languageModel = LanguageViewModel.SupportedLocales().First(x => x.Code == language);

            return(View(languageModel));
        }
Beispiel #15
0
        public ActionResult Save(Language language)
        {
            if (!ModelState.IsValid)
            {
                var viewModel = new LanguageViewModel
                {
                    Language = language,
                    Courses  = _context.Courses.ToList()
                };
                return(View("LanguageForm", viewModel));
            }


            if (language.Id == 0)
            {
                _context.Languages.Add(language);
            }
            else
            {
                var languageInDb = _context.Languages.Single(c => c.Id == language.Id);
                languageInDb.Name = language.Name;
            }
            _context.SaveChanges();
            return(RedirectToAction("Index", "Languages"));
        }
Beispiel #16
0
        // GET: Language/Edit/5
        public async Task <IActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var language = await _context.Language.SingleOrDefaultAsync(m => m.LanguageId == id);

            if (language == null)
            {
                return(NotFound());
            }

            ViewData["Proficiency"] = new SelectList(_context.Language, "Proficiency", "Proficiency", language.UserId == _userId);

            LanguageViewModel viewModel = new LanguageViewModel
            {
                LanguageId      = language.LanguageId,
                Language1       = language.Language1,
                Proficiency     = language.Proficiency,
                PrimaryLanguage = language.PrimaryLanguage,
                UserId          = _userId
            };

            return(View(viewModel));
        }
Beispiel #17
0
 public BerryContext() {
     if (VM_Berry == null) {
         VM_Berry = new BerryViewModel();
     }
     if (VM_Item == null) {
         VM_Item = new ItemViewModel();
     }
     if (VM_Type == null) {
         VM_Type = new TypeViewModel();
     }
     if (VM_Category == null) {
         VM_Category = new CategoryViewModel();
     }
     if (VM_Pocket == null) {
         VM_Pocket = new PocketViewModel();
     }
     if (VM_Generation == null) {
         VM_Generation = new GenerationViewModel();
     }
     if (VM_Region == null) {
         VM_Region = new RegionViewModel();
     }
     if (VM_DamageClass == null) {
         VM_DamageClass = new DamageClassViewModel();
     }
     if (VM_Language == null) {
         VM_Language = new LanguageViewModel();
     }
     if (VM_ContestType == null) {
         VM_ContestType = new ContestTypeViewModel();
     }
 }
        public IHttpActionResult UpdatePost(LanguageViewModel model)
        {
            var response = new SimpleResponse();

            response = iLanguageBusiness.Update(model);
            return(Json(response));
        }
        public async Task WriteLanguageFiles()
        {
            const string translationExportUrl = "https://api.assistantapps.com/TranslationExport/{0}/{1}";
            const string appGuid = "dfe0dbc7-8df4-47fb-a5a5-49af1937c4e2";

            BaseExternalApiRepository apiRepo = new BaseExternalApiRepository();
            ResultWithValue <List <LanguageViewModel> > langResult = await apiRepo.Get <List <LanguageViewModel> >("https://api.assistantapps.com/Language");

            if (langResult.HasFailed)
            {
                Console.WriteLine("Could not get Server Languages");
                return;
            }

            foreach (string languageFile in LangFile.LanguagesInTheApp)
            {
                string            langCode      = languageFile.Replace("language.", string.Empty).Replace(".json", string.Empty);
                LanguageViewModel langViewModel = langResult.Value.FirstOrDefault(l => l.LanguageCode.Equals(langCode));
                if (langViewModel == null)
                {
                    continue;
                }

                ResultWithValue <Dictionary <string, string> > languageContent = await apiRepo.Get <Dictionary <string, string> >(translationExportUrl.Replace("{0}", appGuid).Replace("{1}", langViewModel.Guid.ToString()));

                if (languageContent.HasFailed)
                {
                    continue;
                }

                _languageFileSysRepo.WriteBackToJsonFile(languageContent.Value, languageFile);
            }
        }
 public ActionResult Edit(LanguageViewModel model)
 {
     //if(ModelState.IsValid){
     model.Edit();
     //}
     return(RedirectToAction("Index"));
 }
Beispiel #21
0
        public async Task <ActionResult> Delete(LanguageViewModel model)
        {
            try
            {
                if (!await APIProvider.Authorization(_userSession.BearerToken, ARS.Delete))
                {
                    TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.FuntionType.Article, APIConstant.ACTION_DELETE);
                    return(RedirectToAction("Index"));
                }
                else
                {
                    return(PartialView("_Delete", model));
                }
            }
            catch (HttpException ex)
            {
                Logger.LogError(ex);
                int statusCode = ex.GetHttpCode();
                if (statusCode == 401)
                {
                    TempData["Alert"] = ApplicationGenerator.RenderResult(FuntionType.Department, APIConstant.ACTION_ACCESS);
                    return(new HttpUnauthorizedResult());
                }

                throw ex;
            }
        }
Beispiel #22
0
 public async Task New(LanguageViewModel model)
 {
     if (ModelState.IsValid)
     {
         await _service.New(Mapper.Map <Language>(model));
     }
 }
Beispiel #23
0
        private void ProductsDataGrid_Sorting(object sender, DataGridSortingEventArgs e)
        {
            e.Handled = true;
            LanguageViewModel mainViewModel = (LanguageViewModel)DataContext;
            string            sortField     = String.Empty;

            switch (e.Column.SortMemberPath)
            {
            case ("pid"):
                sortField = "pid";
                break;

            case ("pdate"):
                sortField = "pdate";
                break;
            }

            ListSortDirection direction = (e.Column.SortDirection != ListSortDirection.Ascending) ?
                                          ListSortDirection.Ascending : ListSortDirection.Descending;

            bool sortAscending = direction == ListSortDirection.Ascending;

            mainViewModel.Sort(sortField, sortAscending);

            currentSortColumn.SortDirection = null;

            e.Column.SortDirection = direction;

            currentSortColumn    = e.Column;
            currentSortDirection = direction;
        }
        /// <summary>
        /// Deletes entity for LanguageViewModel.
        /// </summary>
        /// <param name="viewModel">The viewModel <see cref="LanguageViewModel"/>.</param>
        /// <returns>The <see cref="SimpleResponse"/>.</returns>
        public SimpleResponse Delete(LanguageViewModel model)
        {
            var response = new SimpleResponse();

            try
            {
                using (var context = new PublicCoreDbContext())
                {
                    var entity = context.Language.SingleOrDefault(q => q.LanguageId == model.LanguageId);
                    if (entity == null || entity == default(Language))
                    {
                        response.ResponseCode    = BusinessResponseValues.NullEntityValue;
                        response.ResponseMessage = "Kayýt bulunamadý.";
                        return(response);
                    }

                    context.Language.Remove(entity);
                    response.ResponseCode = context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                response.ResponseCode    = BusinessResponseValues.InternalError;
                response.ResponseMessage = "Silme iþleminde hata oluþtu.";
                DayLogger.Error(ex);
            }

            return(response);
        }
        /// <summary>
        /// The Creates entity for LanguageViewModel.
        /// </summary>
        /// <param name="viewModel">The viewModel <see cref="LanguageViewModel"/>.</param>
        /// <returns>The <see cref="SimpleResponse{LanguageViewModel}"/>.</returns>
        public SimpleResponse <LanguageViewModel> Create(LanguageViewModel model)
        {
            var response = new SimpleResponse <LanguageViewModel>();

            try
            {
                var validation = model.Validate();
                if (validation.HasError)
                {
                    return(new SimpleResponse <LanguageViewModel>
                    {
                        Data = model,
                        ResponseCode = BusinessResponseValues.ValidationErrorResult,
                        ResponseMessage = validation.AllValidationMessages
                    });
                }

                using (var context = new PublicCoreDbContext())
                {
                    var entity = Map <LanguageViewModel, Language>(model);
                    context.Language.Add(entity);
                    response.ResponseCode = context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                response.ResponseCode    = BusinessResponseValues.InternalError;
                response.ResponseMessage = "Ekleme iþleminde hata oluþtu.";
                DayLogger.Error(ex);
            }

            return(response);
        }
        public LanguageView()
        {
            this.InitializeComponent();
            ViewModelLocator myVML = new ViewModelLocator();

            myLanguageVM = myVML.LanguageVM;
        }
Beispiel #27
0
        public bool UpdateDictionary(LanguageViewModel languageViewModel)
        {
            var dbContext = new DBContext();

            try
            {
                var           dataSet       = new DataSet();
                var           parameters    = Array.Empty <SqlParameter>();
                PermissionDAL permissionDAL = new PermissionDAL();

                parameters = new SqlParameter[3];

                parameters[0] = dbContext.CreateParameters("@languageID", languageViewModel.Id);
                parameters[1] = dbContext.CreateParameters("@key", languageViewModel.Dictionary.First().Key);
                parameters[2] = dbContext.CreateParameters("@value", languageViewModel.Dictionary.First().Value);



                if (dbContext.Write("UpdateDictionary", parameters) > 0)
                {
                    return(true);
                }

                return(false);
            }
            catch (Exception ex)
            {
                throw new Exception(Messages.Generic_Error);
            }
        }
        // GET: PeopleController
        public ActionResult Index()
        {
            LanguageViewModel languageList = _languageService.All();

            PeopleViewModel personList = _peopleService.All();

            return(View(personList.personList));
        }
Beispiel #29
0
        public static CreateLanguageRequest ConvertToCreateLanguageRequest(this LanguageViewModel model)
        {
            CreateLanguageRequest request = new CreateLanguageRequest();

            request.Language = model.Language;

            return(request);
        }
        public Language FromViewModel(int profileId, LanguageViewModel languageViewModel)
        {
            var language = _mapper.Map <LanguageViewModel, Language>(languageViewModel);

            language.TraineeProfileId = profileId;

            return(language);
        }
        public virtual ActionResult Create(LanguageViewModel language)
        {
            if (ModelState.IsValid)
            {
                languageService.Save(language.MapTo(new Language()));
                return RedirectToAction("ShowAll");
            }

            return View("Admin/New", language);
        }
        public virtual ActionResult Edit(long? id, LanguageViewModel languageModel)
        {
            if (ModelState.IsValid && id != null)
            {
                Language language = languageService.Find((long)id);
                languageService.Save(languageModel.MapTo(language));
                return RedirectToAction("ShowAll");
            }

            return View("Admin/Edit", languageModel);
        }