コード例 #1
0
ファイル: UserService.cs プロジェクト: Speedie007/Intergrator
        /// <summary>
        ///
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public virtual IEntityCRUDResponse AddUserLanguage(IntegratorUserLanguages entity)
        {
            try
            {
                if (entity.IsPrimaryLanguage)
                {
                    /*if the language to be added is set as the primary
                     * //language the get all othe assocciated languages and set them to false for the primary language
                     */
                    var ListOfAllUserLanguages = GetUserLanguages();
                    foreach (IntegratorUserLanguages item in ListOfAllUserLanguages)
                    {
                        item.IsPrimaryLanguage = false;
                    }
                    _userLanguagesRepository.Update(ListOfAllUserLanguages);
                }

                _userLanguagesRepository.Insert(entity);
                _entityCRUDResponse.Returned_ID = entity.Id;
                _entityCRUDResponse.Success     = true;
                _entityCRUDResponse.Message     = "Your Language was Successfully Added.";
            }
            catch (Exception e)
            {
                _entityCRUDResponse.Returned_ID = 0;
                _entityCRUDResponse.Success     = false;
                _entityCRUDResponse.Message     = "Your Interest was NOT Successfully Added, - " + e.Message;
            }
            return(_entityCRUDResponse);
        }
コード例 #2
0
ファイル: UserService.cs プロジェクト: Speedie007/Intergrator
        public virtual IEntityCRUDResponse DeleteUserLanguage(IntegratorUserLanguages entity)
        {
            try
            {
                //Gert Interest ID before deleting
                var UserLanguage = _userLanguagesRepository.GetById(entity.Id);
                var RTN_ID       = UserLanguage.LanguageID;
                //Delete the Current USer Interest
                _userLanguagesRepository.Delete(UserLanguage);

                //Returns the ID if the Iterest Not the ID of The "UserInterestID"
                _entityCRUDResponse.Returned_ID = RTN_ID;
                _entityCRUDResponse.Success     = true;
                _entityCRUDResponse.Message     = "Your Language was Successfully Removed.";
            }
            catch (Exception e)
            {
                _entityCRUDResponse.Returned_ID = 0;
                _entityCRUDResponse.Success     = false;
                _entityCRUDResponse.Message     = "Your Interest was NOT Successfully Removed, - " + e.Message;
            }
            return(_entityCRUDResponse);
        }