コード例 #1
0
        public ActionResult Edit(LanguagesModel modifiedModel, string FILTER_Keyword, int?FILTER_Active)
        {
            if (ModelState.IsValid)
            {
                if (isExists(modifiedModel.Id, modifiedModel.Name))
                {
                    ModelState.AddModelError(LanguagesModel.COL_Name.Name, $"{modifiedModel.Name} sudah terdaftar");
                }
                else
                {
                    LanguagesModel originalModel = db.Languages.AsNoTracking().Where(x => x.Id == modifiedModel.Id).FirstOrDefault();

                    string log = string.Empty;
                    log = Helper.append(log, originalModel.Name, modifiedModel.Name, LanguagesModel.COL_Name.LogDisplay);
                    log = Helper.append(log, originalModel.Active, modifiedModel.Active, LanguagesModel.COL_Active.LogDisplay);

                    if (!string.IsNullOrEmpty(log))
                    {
                        db.Entry(modifiedModel).State = EntityState.Modified;
                        ActivityLogsController.AddEditLog(db, Session, modifiedModel.Id, log);
                        db.SaveChanges();
                    }

                    return(RedirectToAction(nameof(Index), new { FILTER_Keyword = FILTER_Keyword, FILTER_Active = FILTER_Active }));
                }
            }

            setViewBag(FILTER_Keyword, FILTER_Active);
            return(View(modifiedModel));
        }
コード例 #2
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;
            }
        }
コード例 #3
0
        //------------------------------------------------------------------------------------------------------
        #endregion

        #region /*--------- PopulateModelFromIDataReader ---------*\
        //------------------------------------------------------------------------------------------------------
        /// <summary>
        /// Populates model from IDataReader .
        /// </summary>
        /// <param name="reader"></param>
        /// <returns>Model object.</returns>
        //--------------------------------------------------------------------
        private LanguagesModel PopulateModelFromIDataReader(IDataReader reader)
        {
            //Create a new object
            LanguagesModel LanguagesObj = new LanguagesModel();
            //Fill the object with data

			//------------------------------------------------
			//[LangID]
			//------------------------------------------------
			if (reader["LangID"] != DBNull.Value)
			    LanguagesObj.LangID = (int)reader["LangID"];
			//------------------------------------------------
			//------------------------------------------------
			//[Name]
			//------------------------------------------------
			if (reader["Name"] != DBNull.Value)
			    LanguagesObj.Name = (string)reader["Name"];
			//------------------------------------------------
			//------------------------------------------------
			//[Code]
			//------------------------------------------------
			if (reader["Code"] != DBNull.Value)
			    LanguagesObj.Code = (string)reader["Code"];
			//------------------------------------------------
			//------------------------------------------------
			//[LocalizationCode]
			//------------------------------------------------
			if (reader["LocalizationCode"] != DBNull.Value)
			    LanguagesObj.LocalizationCode = (string)reader["LocalizationCode"];
			//------------------------------------------------
            //Return the populated object
            return LanguagesObj;
        }
コード例 #4
0
 public ActionResult Update(LanguagesModel LanguagesObj)
 {
     //------------------------------------------
     //Check ModelState
     //------------------------------------------
     if (!ModelState.IsValid)
     {
         return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError, "Invalid data"));
     }
     //------------------------------------------
     try
     {
         bool result = LanguagesFactor.Update(LanguagesObj);
         if (result == true)
         {
             return(List(1, 25, null, null, null, null));
         }
         else
         {
             return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError, "Saving operation faild"));
         }
     }
     catch (Exception ex)
     { return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError, ex.Message)); }
 }
コード例 #5
0
        public ActionResult Index()
        {
            MyContextClass        mcontextClass   = new MyContextClass();
            List <SelectListItem> selectListItems = new List <SelectListItem>();

            foreach (Languages l in mcontextClass.Languages)
            {
                //create: C# 1 true(selected),C 2 false(notselected),Java 3 true ,...
                SelectListItem selectListItem = new SelectListItem()
                {
                    Text  = l.Name,
                    Value = l.ID.ToString(),
                    // Selected=l.isSelected
                };
                //put each row(Java 3 true) in the list
                selectListItems.Add(selectListItem);
            }//end of foreach

            LanguagesModel languagesModel = new LanguagesModel();

            languagesModel.LanguagesINLanguagesClass = selectListItems;
            //send languagesModel (that have all languages in LanguagesINLanguagesClass object,and will has in view all selected languages in SelectedLanguages Object

            return(View(languagesModel));
        }
コード例 #6
0
        //------------------------------------------------------------------------------------------------------
        #endregion

        #region /*--------- Create ---------*\
        //------------------------------------------------------------------------------------------------------
        /// <summary>
        /// Converts the  object properties to SQL paramters and executes the create  procedure 
        /// and updates the object with the SQL data by reference.
        /// </summary>
        /// <param name="LanguagesObj">Model object.</param>
        /// <returns>The result of create query.</returns>
        //--------------------------------------------------------------------
        public bool Create(LanguagesModel LanguagesObj)
        {
            bool result = false;
            using (SqlConnection myConnection = GetSqlConnection())
            {
                SqlCommand myCommand = new SqlCommand("[dbo].[Languages_Create]", myConnection);
                myCommand.CommandType = CommandType.StoredProcedure;
                //----------------------------------------------------------------------------------------------
                // Set the parameters
                //----------------------------------------------------------------------------------------------
				myCommand.Parameters.Add("@LangID", SqlDbType.Int).Value = LanguagesObj.LangID;
				myCommand.Parameters.Add("@Name", SqlDbType.NVarChar).Value = LanguagesObj.Name;
				myCommand.Parameters.Add("@Code", SqlDbType.VarChar).Value = LanguagesObj.Code;
				myCommand.Parameters.Add("@LocalizationCode", SqlDbType.VarChar).Value = LanguagesObj.LocalizationCode;

                //----------------------------------------------------------------------------------------------
                // Execute the command
                //----------------------------------------------------------------------------------------------
                myConnection.Open();
                if (myCommand.ExecuteNonQuery() > 0)
                {
                    result = true;
                    //Get ID value from database and set it in object

                }
                myConnection.Close();
                return result;
                //----------------------------------------------------------------------------------------------
            }
        }
コード例 #7
0
        public async Task <ActionResult> Create(LanguageViewModel model, HttpPostedFileBase fileUpload)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (fileUpload != null)
                    {
                        model.Icon = FileManagement.ImageToByteArray(fileUpload);
                    }

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

                    if (result)
                    {
                        TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.SUCCESS, ApplicationGenerator.GeneralActionMessage(APIConstant.ACTION_INSERT, ApplicationGenerator.TypeResult.SUCCESS));
                    }
                    else
                    {
                        TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.FAIL, ApplicationGenerator.GeneralActionMessage(APIConstant.ACTION_INSERT, ApplicationGenerator.TypeResult.FAIL));
                    }
                    return(RedirectToAction("Index"));
                }
                else
                {
                    var languages = new LanguagesModel();
                    if (TempData["Data"] != null)
                    {
                        languages.lstLanguageViewModel = (List <LanguageViewModel>)TempData["Data"];
                    }
                    else
                    {
                        languages.lstLanguageViewModel = await APIProvider.Authorize_Get <List <LanguageViewModel> >(_userSession.BearerToken, controllerName, APIConstant.API_Resource_CMS, ARS.Get);
                    }

                    languages.LanguageViewModel = model;

                    TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.FAIL, ApplicationGenerator.GeneralActionMessage(APIConstant.ACTION_INSERT, ApplicationGenerator.TypeResult.FAIL));
                    return(View("Index", languages));
                }
            }
            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;
            }
        }
コード例 #8
0
        public IActionResult ErrorIndex(string errorMsg)
        {
            var langs = LanguagesService.GetAll().ToArray();
            var model = new LanguagesModel()
            {
                AvailableLanguages = langs, AlertMessage = errorMsg, AlertType = AlertType.Error
            };

            return(View("Index", model));
        }
コード例 #9
0
 public LanguagesModel GetLanguages()
 {
     try
     {
         return(LanguagesModel.FromJson(HTMLGet($"{_baseURL}api/languages")));
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
コード例 #10
0
        //------------------------------------------------------------------------------------------------------
        #endregion

        #region --------------GetObject--------------
        //------------------------------------------------------------------------------------------------------
        /// <summary>
        /// Gets the spesific record.
        /// </summary>
        /// <param name="ID">The model id.</param>
        /// <returns>Model object.</returns>
        //--------------------------------------------------------------------
        public static LanguagesModel GetObject(int LangID)
        {
            LanguagesModel        LanguagesObj = null;
            List <LanguagesModel> list         = LanguagesSqlDataPrvider.Instance.Get(LangID);

            if (list != null && list.Count > 0)
            {
                LanguagesObj = list[0];
            }
            return(LanguagesObj);
        }
コード例 #11
0
        public ActionResult Languages(LanguagesModel modelData)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            modelData.UserId = _userId;
            var entityData = ModelToEntityMapper.ConvertToEntity <TblLanguages, LanguagesModel>(modelData);
            var repo       = new Repository <TblLanguages>(new DatabaseEntities());

            repo.Update(entityData);

            return(RedirectToAction("Index", "PrivateArea"));
        }
コード例 #12
0
 public ActionResult GetObject(int id)
 {
     try
     {
         LanguagesModel LanguagesObj = LanguagesFactor.GetObject(id);
         if (LanguagesObj == null)
         {
             LanguagesObj = new LanguagesModel();
         }
         return(Json(LanguagesObj, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError, ex.Message));
     }
 }
コード例 #13
0
        public IActionResult Index()
        {
            try
            {
                var langs = LanguagesService.GetAll().ToArray();
                var model = new LanguagesModel()
                {
                    AvailableLanguages = langs
                };

                return(View(model));
            }
            catch (Exception e)
            {
                return(View("Error", new ErrorViewModel {
                    Exception = e, RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier
                }));
            }
        }
コード例 #14
0
        public ActionResult Create(LanguagesModel model, string FILTER_Keyword, int?FILTER_Active)
        {
            if (ModelState.IsValid)
            {
                if (isExists(null, model.Name))
                {
                    ModelState.AddModelError(LanguagesModel.COL_Name.Name, $"{model.Name} sudah terdaftar");
                }
                else
                {
                    model.Id     = Guid.NewGuid();
                    model.Active = true;
                    db.Languages.Add(model);
                    ActivityLogsController.AddCreateLog(db, Session, model.Id);
                    db.SaveChanges();
                    return(RedirectToAction(nameof(Index), new { id = model.Id, FILTER_Keyword = FILTER_Keyword, FILTER_Active = FILTER_Active }));
                }
            }

            setViewBag(FILTER_Keyword, FILTER_Active);
            return(View(model));
        }
コード例 #15
0
        public LanguagePicker(bool isUserLanguage, ContentPage parent, LanguagesModel model)
        {
            InitializeComponent();

            IsUserLanguage = isUserLanguage;
            ParentPage     = parent;

            viewModel = model;
            //viewModel.LanguagesLoaded += ViewModel_LanguagesLoaded;

            Languages.ItemsSource  = viewModel.Languages;
            Languages.ItemTemplate = new DataTemplate(typeof(LanguagePickerListItemCell));

            Languages.ItemTapped += Languages_ItemTapped;

            if (isUserLanguage)
            {
                Title.Text = "Pick Your Language";
            }
            else
            {
                Title.Text = "Pick Translation Language";
            }
        }
コード例 #16
0
        public AppViewModel()
        {
            // Create LoginInfoModel
            LoginInfoModel = new LoginInfoModel
            {
                ButtonLoginOrLogoutCommand = new RelayCommand <object>(new Action <object>(LoginOrLogoutCommand), new Predicate <object>(LoginOrLogoutCommandCanExecute))
            };

            // Create ConversationModel
            ConversationModel = new ConversationModel
            {
                ButtonRejectCommand        = new RelayCommand <object>(new Action <object>(RejectCommand), new Predicate <object>(RejectCommandCanExecute)),
                ButtonHangUpCommand        = new RelayCommand <object>(new Action <object>(HangUpCommand), new Predicate <object>(HangUpCommandCanExecute)),
                ButtonAnswerCommand        = new RelayCommand <object>(new Action <object>(AnswerCommand), new Predicate <object>(AnswerCommandCanExecute)),
                ButtonCallCommand          = new RelayCommand <object>(new Action <object>(CallCommand), new Predicate <object>(CallCommandCanExecute)),
                ButtonSelectDevicesCommand = new RelayCommand <object>(new Action <object>(SelectDevicesCommand), new Predicate <object>(SelectDevicesCommandCanExecute)),

                ButtonMuteUnmuteAudioCommand   = new RelayCommand <object>(new Action <object>(MuteUnmuteAudioCommand), new Predicate <object>(MuteUnmuteAudioCommandCanExecute)),
                ButtonMuteUnmuteVideoCommand   = new RelayCommand <object>(new Action <object>(MuteUnmuteVideoCommand), new Predicate <object>(MuteUnmuteVideoCommandCanExecute)),
                ButtonMuteUnmuteSharingCommand = new RelayCommand <object>(new Action <object>(MuteUnmuteSharingCommand), new Predicate <object>(MuteUnmuteSharingCommandCanExecute)),

                ButtonAddAudioCommand         = new RelayCommand <object>(new Action <object>(AddAudioCommand), new Predicate <object>(AddAudioCommandCanExecute)),
                ButtonAddRemoveVideoCommand   = new RelayCommand <object>(new Action <object>(AddRemoveVideoCommand), new Predicate <object>(AddRemoveVideoCommandCanExecute)),
                ButtonAddRemoveSharingCommand = new RelayCommand <object>(new Action <object>(AddRemoveSharingCommand), new Predicate <object>(AddRemoveSharingCommandCanExecute)),
            };

            // Create LayoutModel
            LayoutModel = new LayoutModel();
            LayoutModel.LocalVideo.ButtonSetCommand = new RelayCommand <object>(new Action <object>(SetLocalVideoCommand));
            LayoutModel.LocalVideo.ButtonPictureInPictureSwitchCommand = new RelayCommand <object>(new Action <object>(SwitchPictureInPictureModeOnLocalVideoCommand));
            LayoutModel.RemoteVideo.ButtonSetCommand = new RelayCommand <object>(new Action <object>(SetRemoteVideoCommand));
            LayoutModel.RemoteVideo.ButtonPictureInPictureSwitchCommand = new RelayCommand <object>(new Action <object>(SwitchPictureInPictureModeOnRemoteVideoCommand));
            LayoutModel.Sharing.ButtonSetCommand = new RelayCommand <object>(new Action <object>(SetSharingCommand));
            LayoutModel.Sharing.ButtonPictureInPictureSwitchCommand = new RelayCommand <object>(new Action <object>(SwitchPictureInPictureModeOnSharingCommand));

            LayoutModel.PropertyChanged += LayoutModel_PropertyChanged;

            // Create DevicesModel
            DevicesModel = new DevicesModel();

            // Create UsersModel
            UsersModel = new UsersModel();

            // Create LanguagesModel
            LanguagesModel = new LanguagesModel()
            {
                ButtonSetCommand = new RelayCommand <object>(new Action <object>(SetLanguageCommand))
            };

            // Get Rainbow Languages service
            rbLanguages = Rainbow.Common.Languages.Instance;
            SetLanguagesList(rbLanguages.GetLanguagesIdList());

            // Create ConstraintModel
            ConstraintModel = new ConstraintModel()
            {
                MaxFrameRateValue          = "10",
                WidthValue                 = "640",
                HeightValue                = "480",
                VideoConstraint            = true,
                ButtonSetConstraintCommand = new RelayCommand <object>(new Action <object>(SetConstraintCommand), new Predicate <object>(SetConstraintCommandCanExecute))
            };
        }
コード例 #17
0
        //------------------------------------------------------------------------------------------------------
        #endregion

        #region --------------Update--------------
        //------------------------------------------------------------------------------------------------------
        /// <summary>
        /// Updates model object by calling sql data provider update method.
        /// </summary>
        /// <param name="LanguagesObj">The model object.</param>
        /// <returns>The result of update operation.</returns>
        //--------------------------------------------------------------------
        public static bool Update(LanguagesModel LanguagesObj)
        {
            return(LanguagesSqlDataPrvider.Instance.Update(LanguagesObj));
        }