public dynamic Register([FromBody] Users account) { int wynik = CheckRegistration(account.Email, account.Login); if (wynik == 0) { account.PasswordHash(); _dbcontext.User.Add(account); _dbcontext.SaveChanges(); SendMail sendMail = new SendMail(); string massege = "Witaj," + System.Environment.NewLine + "Dziękujemy za rejestrację w DziejeSie," + System.Environment.NewLine + "z nami będziesz zawsze na czasie z wydarzeniami w twojej okolicy" + System.Environment.NewLine + "Pozdrawiamy" + System.Environment.NewLine + "Zespół DziejeSie"; sendMail.send("*****@*****.**", account.Email, "Witaj w DziejeSie", massege, "zaq1@WSX"); var User = new { Iduser = account.IdUser, Login = account.Login, Email = account.Email, FirstName = account.Firstname, LastName = account.LastName, Address = account.Address, PostCode = account.PostCode, Town = account.Town, RegisterDate = account.RegisterDate.ToString("dd-MM-yyy"), RegisterHour = account.RegisterDate.ToString("HH:mm") }; return(User); } else if (wynik == 1) { var Error = new { Kod = 1, Typ = "Rejestracka", Opis = "Podany email jest zajety" }; return(Error); } else { var Error = new { Kod = 1, Typ = "Rejestracka", Opis = "Podany Login jest zajety" }; return(Error); } }
public dynamic AddComment(Comments Comment) { try { Events Event = _dbcontext.Event.Single(x => x.EventId.Equals(Comment.EventId)); _dbcontext.Add(Comment); _dbcontext.SaveChanges(); } catch (System.Exception) { return(new { Code = 1, Type = "CommentAdd", Desc = "Event does not exist" }); } return(new { Code = 0, Type = "CommentAdd", Desc = "Success" }); }
public dynamic AddNewEvent([FromBody] Events events) { _dbcontext.Event.Add(events); _dbcontext.SaveChanges(); Users User = new Users(); User = _dbcontext.User.Single(x => x.IdUser == events.UserId); var Event = new { EventId = events.EventId, Name = events.Name, Description = events.Description, Category = events.Category, Address = events.Address, Postcode = events.Postcode, Town = events.Town, User = User.Login, EventDate = events.EventDate.ToString("dd-MM-yyy"), EventHour = events.EventDate.ToString("HH:mm") }; return(Event); }
public dynamic Positive(int UserId, int EventId) { if (!UserExists(UserId)) { var Error = new { Code = 1, Type = "Upvote", Desc = "User does not exist" }; return(Error); } // sprawdzanie czy istnieje użyszkodnik if (!EventExists(EventId)) { var Error = new { Code = 2, Type = "Upvote", Desc = "Event does not exist" }; return(Error); } //sprawdzanie czy istnieje event o danym id int UpvoteValue = UpvoteExists(EventId, UserId); Upvotes Upvote = new Upvotes(); if (UpvoteValue == 0) { //brak wpisu dla kombinacji UxE --> dodanie informacji do bazy Upvote.EventId = EventId; Upvote.UserId = UserId; Upvote.Value = 1; _dbcontext.Upvote.Add(Upvote); _dbcontext.SaveChanges(); } else { if (UpvoteValue == 1) //usuwanie wpisu { Upvote = _dbcontext.Upvote.Single(x => x.UserId == UserId && x.EventId == EventId); _dbcontext.Remove(Upvote); _dbcontext.SaveChanges(); } else if (UpvoteValue == -1) // modyfikowanie wpisu { Upvote = _dbcontext.Upvote.Single(x => x.UserId == UserId && x.EventId == EventId); Upvote.Value = 1; _dbcontext.SaveChanges(); } } var Message = new { Code = 0, Type = "Upvote", Desc = "Success" }; return(Message); }