private void InitializeFields()
    {
        DataClassesDataContext dc          = new DataClassesDataContext();
        List <Suscription>     allRequests = SubscriptionWrapper.getByUserId(((UserAccount)Session["loggedUser"]).UserID);

        int count = allRequests.Count;

        controls = new List <Controls_RequestControl>(count);
        table.Controls.Clear();

        for (int index = 0; index < count; index++)
        {
            Suscription suscription = allRequests[index];
            TableRow    rowNew      = new TableRow();
            table.Controls.Add(rowNew);

            var       reqID   = suscription.RequestID;
            Request   request = RequestWrapper.getById(reqID);
            TableCell cellNew = new TableCell();

            //Label lblNew = new Label();
            //lblNew.Text = request.Title + " " + request.StartDate + " " + request.EndDate + " "
            //                        + request.MinUsers + " " + request.MaxUsers + " " + request.City + " "
            //                        + request.State + " " + request.Sector + " " + request.Street + " "
            //                        + request.Status + "<br />";

            UserControl uc = (UserControl)Page.LoadControl("../Controls/RequestControl.ascx");
            ((Controls_RequestControl)uc).Request = request;
            Button subscribeButton = (Button)((Controls_RequestControl)uc).FindControl("subscribeButton");
            subscribeButton.Visible = false;
            controls.Add((Controls_RequestControl)uc);
            cellNew.Controls.Add((Controls_RequestControl)uc);
            rowNew.Controls.Add(cellNew);
        }
    }
예제 #2
0
        public int update(Suscription suscription)
        {
            db.Connection.Open();
            int result = db.Connection.Execute(StoreProcedureNames.Suscription.Update, new { Id = suscription.Id, Name = suscription.Name, Description = suscription.Description, Number_Case = suscription.Number_Case }, commandType: CommandType.StoredProcedure);

            db.Connection.Close();
            return(result);
        }
예제 #3
0
        public int delete(Suscription suscription)
        {
            db.Connection.Open();
            int result = db.Connection.Execute(StoreProcedureNames.Suscription.Delete, new { Id = suscription.Id }, commandType: CommandType.StoredProcedure);

            db.Connection.Close();
            return(result);
        }
        public void Unsubscribe([FromBody] Suscription sub)
        {
            var  userName = User.Identity.Name;
            User user     = _context.Users.Where(a => a.Email == userName).Include(a => a.UserDates).FirstOrDefault();

            user.UserDates.Suscribed = false;
            user.Suscription         = null;
            _context.SaveChanges();
        }
예제 #5
0
    public void update(Suscription sub)
    {
        DataClassesDataContext dc     = new DataClassesDataContext();
        Suscription            subAcc = dc.Suscriptions.Single(u => u.ID == sub.ID);

        subAcc.RequestID = sub.RequestID;
        subAcc.UserID    = sub.UserID;

        dc.SubmitChanges();
    }
예제 #6
0
    public void Save()
    {
        DataClassesDataContext dc  = new DataClassesDataContext();
        Suscription            sub = new Suscription();

        sub.RequestID = this.RequestID;
        sub.UserID    = this.UserID;

        dc.Suscriptions.InsertOnSubmit(sub);
        dc.SubmitChanges();
    }
예제 #7
0
        public ActionResult <object> Update(Suscription suscription)
        {
            AppDB         db            = provider.GetRequiredService <AppDB>();
            SuscriptionDA suscriptionDA = new SuscriptionDA(db);
            var           res           = suscriptionDA.update(suscription);

            return(new
            {
                result = res
            });
        }
 public bool Save(Suscription entity)
 {
     try
     {
         Context.Suscriptions.Add(entity);
         Context.SaveChanges();
     }
     catch (System.Exception)
     {
         return(false);
     }
     return(true);
 }
        public Suscription Get(int id)
        {
            var suscription = new Suscription();

            try
            {
                suscription = Context.Suscriptions.Single(x => x.Id == id);
            }
            catch (System.Exception)
            {
                throw;
            }
            return(suscription);
        }
예제 #10
0
        public bool Update(Suscription entity)
        {
            try
            {
                var suscription = Context.Suscriptions.Single(x => x.Id == entity.Id);

                suscription.Qdays   = entity.Qdays;
                suscription.Qpeople = entity.Qpeople;
                suscription.Subcost = entity.Subcost;
                suscription.UserId  = entity.UserId;

                Context.Suscriptions.Update(suscription);
                Context.SaveChanges();
            }
            catch (System.Exception)
            {
                return(false);
            }
            return(true);
        }
예제 #11
0
        public static Guid SubmitNewPost(Guid AuthorKey, Guid wallOwnerReferenceKey, string text)
        {
            using (var db = new FHNWPrototypeDB())
            {
                Guid newGuid = Guid.NewGuid();
                var wall = db.ContentStreams
                    .Include("Owner")
                    .FirstOrDefault(x => x.Owner.ReferenceKey == wallOwnerReferenceKey);
                var author = db.BasicProfiles.FirstOrDefault(x => x.ReferenceKey == AuthorKey);

                Post newPost = new Post();
                newPost.Author = author;
                newPost.Key = newGuid;
                newPost.PublishDateTime = DateTime.Now;
                newPost.Text = text;
                newPost.Wall = wall;

                db.Posts.Add(newPost);

                Suscription thisSuscription = null;
                Suscription thisSuscription2 = null;
                Event thisEvent = null;
                Notification notification = null;

                //suscribe the author to receive notifications from this post, from now on
                if (AuthorKey != wallOwnerReferenceKey)
                {
                    thisSuscription = new Suscription { Key = Guid.NewGuid(), Type = SuscriptionType.MyPost  , Suscriber = author, ReferencePoint = newGuid };
                    thisSuscription2 = new Suscription { Key = Guid.NewGuid(), Type = SuscriptionType.PostOnMyWall , Suscriber = wall.Owner, ReferencePoint = newGuid };

                    db.Suscriptions.Add(thisSuscription);
                    db.Suscriptions.Add(thisSuscription2);

                    //register the event of liking the post

                    thisEvent = new Event { Key = Guid.NewGuid(), PostOrComment = newGuid, Type = EventType.NewPostOnMyWall , TriggeredBy = author, TriggeredOn = DateTime.Now };

                    db.Events.Add(thisEvent);

                    //dont notify if its yourself

                    notification = new Notification { Key = Guid.NewGuid(), Event = thisEvent, NotifiedTo = wall.Owner };

                    db.Notifications.Add(notification);
                }

                db.SaveChanges();
                return newGuid;
            }
        }
예제 #12
0
        public static Guid SubmitNewComment(Guid AuthorKey, Guid postKey, string text)
        {
            using (var db = new FHNWPrototypeDB())
            {
                Guid  newGuid = Guid.NewGuid();
                var post = db.Posts
                    .Include("Author")
                    .Include("Wall.Owner")
                    .FirstOrDefault(x => x.Key == postKey);
                // var author = db.UserAccounts.Single(x => x.Key == AuthorKey);
                var author = db.BasicProfiles.FirstOrDefault(x => x.ReferenceKey == AuthorKey);

                Comment newComment = new Comment();
                newComment.Author = author;
                newComment.Key = newGuid;
                newComment.PublishDateTime = DateTime.Now;
                newComment.Text = text;
                newComment.Post = post;

                db.Comments.Add(newComment);

                Suscription thisSuscription = null;
                Suscription thisSuscription2 = null;
                Event thisEvent = null;
                Event thisEvent2 = null;
                Notification notification = null;

                //suscribe the author to receive notifications from this post, from now on
                if (AuthorKey != post.Wall.Owner.ReferenceKey)
                {
                    thisSuscription = new Suscription { Key = Guid.NewGuid(), Type = SuscriptionType.MyComment , Suscriber = author, ReferencePoint = newGuid };
                    thisSuscription2 = new Suscription { Key = Guid.NewGuid(), Type = SuscriptionType.CommentOnPostOnMyWall, Suscriber = post.Wall.Owner, ReferencePoint = newGuid };

                    db.Suscriptions.Add(thisSuscription);
                    db.Suscriptions.Add(thisSuscription2);

                    //register the event of liking the post

                    thisEvent = new Event { Key = Guid.NewGuid(), PostOrComment = newGuid, Type = EventType.NewCommentOnPostOnMyWall , TriggeredBy = author, TriggeredOn = DateTime.Now };
                    thisEvent2 = new Event { Key = Guid.NewGuid(), PostOrComment = newGuid, Type = EventType.NewCommentOnPostILiked,  TriggeredBy = author, TriggeredOn = DateTime.Now };

                    db.Events.Add(thisEvent);
                    db.Events.Add(thisEvent2);

                    //dont notify if its yourself

                    notification = new Notification { Key = Guid.NewGuid(), Event = thisEvent, NotifiedTo = post.Wall.Owner };
                    db.Notifications.Add(notification);

                    var suscriptions = db.Suscriptions.Where(x => x.ReferencePoint == post.Key && x.Type == SuscriptionType.PostILiked).ToList();

                    foreach (Suscription suscription in suscriptions)
                    {
                        db.Notifications.Add(new Notification { Key=Guid.NewGuid(), Event=thisEvent2 , NotifiedTo = suscription.Suscriber   });
                    }

                }

                db.SaveChanges();
                return newGuid;
            }
        }
예제 #13
0
        public static int LikePost(Guid AuthorKey, Guid postKey)
        {
            using (var db = new FHNWPrototypeDB())
            {
                var thisPost = db.Posts
                    .Include("PostLikes")
                    .Include("Author")
                    .Single(x => x.Key == postKey);
                var author = db.BasicProfiles.FirstOrDefault(x => x.ReferenceKey == AuthorKey);
                PostLike newLike = new PostLike();
                Guid newGuid = Guid.NewGuid();
                newLike.Key = newGuid;
                newLike.Author = author;
                newLike.DateTime = DateTime.Now;
                newLike.Value = LikeValue.Positive;
                newLike.Post = thisPost;
                db.PostLikes.Add(newLike);

                Suscription thisSuscription = null;
                Event thisEvent = null;
                Notification notification = null;

                //suscribe the author to receive notifications from this post, from now on
                if (AuthorKey != author.ReferenceKey)
                {
                     thisSuscription = new Suscription { Key = Guid.NewGuid(), Type = SuscriptionType.PostILiked, Suscriber = author, ReferencePoint = newGuid };

                    db.Suscriptions.Add(thisSuscription);

                //register the event of liking the post

                     thisEvent = new Event { Key = Guid.NewGuid(), PostOrComment = newGuid, Type = EventType.LikedMyPost, TriggeredBy = author, TriggeredOn = DateTime.Now };

                    db.Events.Add(thisEvent);

                //dont notify if its yourself

                    notification = new Notification { Key = Guid.NewGuid(), Event = thisEvent, NotifiedTo = thisPost.Author };

                    db.Notifications.Add(notification);
                }

                db.SaveChanges();
                return thisPost.PostLikes.Count;
            }
        }
예제 #14
0
 private void detach_Suscriptions(Suscription entity)
 {
     this.SendPropertyChanging();
     entity.UserAccount = null;
 }
예제 #15
0
 partial void DeleteSuscription(Suscription instance);
예제 #16
0
 partial void UpdateSuscription(Suscription instance);
예제 #17
0
 partial void InsertSuscription(Suscription instance);
예제 #18
0
 public ActionResult Put([FromBody] Suscription suscription)
 {
     return(Ok(
                suscriptionService.Update(suscription)
                ));
 }
예제 #19
0
 public bool Update(Suscription entity)
 {
     return(suscriptionRepository.Update(entity));
 }
예제 #20
0
 public bool Save(Suscription entity)
 {
     return(suscriptionRepository.Save(entity));
 }
예제 #21
0
 private void detach_Suscriptions(Suscription entity)
 {
     this.SendPropertyChanging();
     entity.Request = null;
 }
예제 #22
0
 public ActionResult Post([FromBody] Suscription suscription)
 {
     return(Ok(
                suscriptionService.Save(suscription)
                ));
 }