Beispiel #1
0
 public UpdateManager(IVkApiService vkApiService, IFriendsService friendsService,
                      DataContextService contextService)
 {
     _vkApiService   = vkApiService;
     _friendsService = friendsService;
     _contextService = contextService;
 }
Beispiel #2
0
        public ActionResult DeletePost(Guid Id)
        {
            var post = db.Posts.Find(Id);

            if (post != null)
            {
                db.Posts.Remove(post);
                db.SaveChanges();
            }

            // return success
            var list = new List <PostViewModel>();

            DataContextService.ApplyEntitySorting(db.Posts.ToList()).ForEach(c => list.Add(new PostViewModel(c)));

            var vm = new PostListViewModel
            {
                Posts = list
            };
            var str    = RenderPartialToStringExtensions.RenderPartialToString(ControllerContext, "DeletePost", vm);
            var result = new
            {
                Data    = str,
                Success = true
            };

            return(Json(result));
        }
        public DataContextViewModel()
        {
            var selectedTreeItemService = ServiceLocator.Resolve <SelectedTreeItemService>();

            selectedTreeItemService.SelectedTreeItemChanged += (s, e) => _updateTrigger.IsUpdateRequired = true;
            _updateTrigger.UpdateAction =
                () => _dataContextService.UpdateDataContext(selectedTreeItemService.SelectedTreeItem);

            _dataContextService = ServiceLocator.Resolve <DataContextService>();
        }
Beispiel #4
0
        /// <summary>
        /// Delete Post View
        /// </summary>
        /// <returns></returns>
        public ActionResult DeletePost()
        {
            var list = new List <PostViewModel>();

            DataContextService.ApplyEntitySorting(db.Posts.ToList()).ForEach(c => list.Add(new PostViewModel(c)));

            var vm = new PostListViewModel
            {
                Posts = list
            };

            return(PartialView("DeletePost", vm));
        }
Beispiel #5
0
        /// <summary>
        /// Delete Caption View
        /// </summary>
        /// <returns></returns>
        public ActionResult DeleteCaption()
        {
            var list = new List <CaptionViewModel>();

            DataContextService.ApplyEntitySorting(db.Captions.ToList()).ForEach(c => list.Add(new CaptionViewModel(c)));

            var vm = new CaptionListViewModel
            {
                Captions = list
            };

            return(PartialView("DeleteCaption", vm));
        }
Beispiel #6
0
        public ActionResult CreatePost(string title, string content, Guid[] id)
        {
            var post = new Post
            {
                PostTitle   = title,
                PostContent = content,
                PostedBy    = SecurityService.GetLoggedInUser().Name,
                Captions    = new List <Caption>()
            };

            if (id != null)
            {
                foreach (var capId in id)
                {
                    var cap = db.Captions.Find(capId);
                    if (cap != null)
                    {
                        post.Captions.Add(cap);
                    }
                }
            }

            db.Posts.Add(post);
            db.SaveChanges();

            // return success
            var list = new List <CaptionViewModel>();

            DataContextService.ApplyEntitySorting(db.Captions.ToList()).ForEach(c => list.Add(new CaptionViewModel(c)));

            var vm = new CaptionListViewModel
            {
                Captions = list
            };
            var str    = RenderPartialToStringExtensions.RenderPartialToString(ControllerContext, "CreatePost", vm);
            var result = new
            {
                Data    = str,
                Success = true
            };

            return(Json(result));
        }
Beispiel #7
0
        private async void btnTestConnection_Click(object sender, EventArgs e)
        {
            SqlConnectionStringBuilder connectionString = new SqlConnectionStringBuilder
            {
                DataSource               = txtServerName.Text,
                InitialCatalog           = txtDatabaseName.Text,
                MultipleActiveResultSets = true,
                ConnectTimeout           = int.Parse(numConnectionTimeout.Text)
            };

            if (string.IsNullOrEmpty(txtUserName.Text) || string.IsNullOrEmpty(txtUserPassword.Text))
            {
                connectionString.IntegratedSecurity = true;
            }
            else
            {
                connectionString.IntegratedSecurity = false;
                connectionString.UserID             = txtUserName.Text;
                connectionString.Password           = txtUserPassword.Text;
            }

            btnTestConnection.Text      = "Встановлення з'єднання ...";
            btnTestConnection.ForeColor = Color.Black;

            AllowEditing(false);

            DataContextService service = new DataContextService(connectionString.ToString());

            bool result = await service.TestConnection(false);

            if (result)
            {
                btnTestConnection.Text      = "З'єднання встановлено";
                btnTestConnection.ForeColor = Color.Green;
            }
            else
            {
                btnTestConnection.Text      = "З'єднання не встановлено";
                btnTestConnection.ForeColor = Color.Red;
            }

            AllowEditing(true);
        }
Beispiel #8
0
        public VkApiService(IConfiguration config, IMessageService messageService, DataContextService contextService)
        {
            _messageService = messageService;
            ulong.TryParse(config["AppId"], out var appId);
            var login      = config["VkAuth:Login"];
            var password   = config["VkAuth:Password"];
            var authParams = new ApiAuthParams
            {
                ApplicationId = appId,
                Settings      = Settings.All,
                Login         = login,
                Password      = password
            };
            var services = new ServiceCollection();

            services.AddAudioBypass();
            _vkApi = new VkApi(services);
            _vkApi.Authorize(authParams);
            _contextService = contextService;
        }
Beispiel #9
0
 public MessageService(DataContextService contextService)
 {
     _contextService = contextService;
 }
Beispiel #10
0
 /// <summary>
 /// Default override for save changes
 /// </summary>
 /// <returns></returns>
 public override int SaveChanges()
 {
     DataContextService.PerformPreSaveChanges(ChangeTracker);
     return(base.SaveChanges());
 }
Beispiel #11
0
 /// <summary>
 /// If this user is validated, log them in
 /// </summary>
 /// <param name="user"></param>
 /// <param name="password"></param>
 public static bool ValidateUserLogin(User user, string password)
 {
     return(user.Password.Equals(DataContextService.ComputeHash(password)));
 }