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); } }
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); }
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(); }
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(); }
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(); }
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); }
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); }
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; } }
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; } }
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; } }
private void detach_Suscriptions(Suscription entity) { this.SendPropertyChanging(); entity.UserAccount = null; }
partial void DeleteSuscription(Suscription instance);
partial void UpdateSuscription(Suscription instance);
partial void InsertSuscription(Suscription instance);
public ActionResult Put([FromBody] Suscription suscription) { return(Ok( suscriptionService.Update(suscription) )); }
public bool Update(Suscription entity) { return(suscriptionRepository.Update(entity)); }
public bool Save(Suscription entity) { return(suscriptionRepository.Save(entity)); }
private void detach_Suscriptions(Suscription entity) { this.SendPropertyChanging(); entity.Request = null; }
public ActionResult Post([FromBody] Suscription suscription) { return(Ok( suscriptionService.Save(suscription) )); }