public List <Event> getAllEvents()
 {
     using (var context = new EventsDBEntities())
     {
         return(context.Events.ToList());
     }
 }
 public List <Event> myEvents(string username)
 {
     using (var context = new EventsDBEntities())
     {
         int id = getUserId(username);
         return(context.Events.Where(allEvents => allEvents.UserId == id).ToList());
     }
 }
 public void addComment(Comment comment)
 {
     using (var context = new EventsDBEntities())
     {
         context.Comments.Add(comment);
         context.SaveChanges();
     }
 }
Beispiel #4
0
        public JsonResult getevents()
        {
            using (EventsDBEntities db = new EventsDBEntities()) {
                var result = db.Events.OrderBy(a => a.StartAt).ToList();

                return(new JsonResult {
                    Data = result, JsonRequestBehavior = JsonRequestBehavior.AllowGet
                });
            }
        }
Beispiel #5
0
        //Return true if the details of the logged in user matched with the database user
        public bool Login(User model)
        {
            using (var context = new EventsDBEntities())
            {
                bool isValidUser = context.Users.Any(User => User.EmailId.ToLower() ==
                                                     model.EmailId.ToLower() && User.Password == model.Password);

                return(isValidUser);
            }
        }
Beispiel #6
0
        //Returns true or false if the user exists in the Database
        public bool UserExists(User model)
        {
            using (var context = new EventsDBEntities())
            {
                bool isValidUser = context.Users.Any(User => User.EmailId.ToLower() ==
                                                     model.EmailId.ToLower());

                return(isValidUser);
            }
        }
 public int getUserId(string username)
 {
     using (var context = new EventsDBEntities())
     {
         int result = (from user in context.Users
                       where user.EmailId == username
                       select user.UserId).FirstOrDefault();
         return(result);
     }
 }
 public int createEvent(Event bookEvent, string username)
 {
     using (var context = new EventsDBEntities())
     {
         bookEvent.UserId = getUserId(username);
         context.Events.Add(bookEvent);
         context.SaveChanges();
         return(bookEvent.EventId);
     };
 }
 public List <Event> getAllPublicEvents()
 {
     using (var context = new EventsDBEntities())
     {
         var requiredEvents = context.Events.OrderBy(allEvents => allEvents.EventDate)
                              .Where(allEvents => allEvents.TypeOfEvent == true)
                              .ToList();
         return(requiredEvents);
     }
 }
Beispiel #10
0
 //Register the user into the database for the given details
 public int SignUp(User model)
 {
     using (var context = new EventsDBEntities())
     {
         context.Users.Add(model);
         UserRolesMapping addRole = new UserRolesMapping();
         addRole.UserId = model.UserId;
         addRole.RoleId = 2;
         context.UserRolesMappings.Add(addRole);
         context.SaveChanges();
         return(model.UserId);
     }
 }
        public Event getDetailsOfEvent(int eventid)
        {
            using (var context = new EventsDBEntities())
            {
                var comments = context.Comments.Where(comment => comment.EventId == eventid)
                               .OrderBy(comment => comment.CreateDate)
                               .ToList();

                var requiredEvent = context.Events.Where(aEvent => aEvent.EventId == eventid).FirstOrDefault();

                return(requiredEvent);
            };
        }
 public void editEvent(Event eventEntity)
 {
     using (var context = new EventsDBEntities())
     {
         var requiredEvent = context.Events.Where(events => events.EventId == eventEntity.EventId).FirstOrDefault();
         requiredEvent.Title         = eventEntity.Title;
         requiredEvent.StartTime     = eventEntity.StartTime;
         requiredEvent.InviteByEmail = eventEntity.InviteByEmail;
         requiredEvent.OtherDetails  = eventEntity.InviteByEmail;
         requiredEvent.TypeOfEvent   = eventEntity.TypeOfEvent;
         requiredEvent.Description   = eventEntity.Description;
         requiredEvent.EventDate     = eventEntity.EventDate;
         requiredEvent.ModifyDate    = DateTime.Now;
         context.SaveChanges();
     }
 }
        public string[] getRolesFromTable(string emailId)
        {
            using (var context = new EventsDBEntities())
            {
                var userRoles = (from user in context.Users
                                 join roleMapping in context.UserRolesMappings
                                 on user.UserId equals roleMapping.UserId
                                 join role in context.RoleMasters
                                 on roleMapping.RoleId equals role.RoleId
                                 where user.EmailId == emailId
                                 select role.RoleName).ToArray();



                return(userRoles);
            }
        }
Beispiel #14
0
        public JsonResult DeleteEvent(int eventID)
        {
            bool status = false;

            using (EventsDBEntities db = new EventsDBEntities())
            {
                var v = db.Events.Where(a => a.EventId.Equals(eventID)).FirstOrDefault();
                if (v != null)
                {
                    db.Events.Remove(v);
                    db.SaveChanges();
                    status = true;
                }
            }
            return(new JsonResult {
                Data = new { status = status }
            });
        }
Beispiel #15
0
        public JsonResult SaveEvent(Event evt)
        {
            bool status = false;

            using (EventsDBEntities db = new EventsDBEntities())
            {
                if (evt.EndAt != null && evt.StartAt.Value.TimeOfDay == new TimeSpan(0, 0, 0) &&
                    evt.EndAt.Value.TimeOfDay == new TimeSpan(0, 0, 0))
                {
                    evt.IsFullDay = true;
                }
                else
                {
                    evt.IsFullDay = false;
                }

                if (evt.EventId > 0)
                {
                    var v = db.Events.Where(a => a.EventId.Equals(evt.EventId)).FirstOrDefault();
                    if (v != null)
                    {
                        v.Title       = evt.Title;
                        v.Description = evt.Description;
                        v.StartAt     = evt.StartAt;
                        v.EndAt       = evt.EndAt;
                        v.IsFullDay   = evt.IsFullDay;
                    }
                }
                else
                {
                    db.Events.Add(evt);
                }
                db.SaveChanges();
                status = true;
            }
            return(new JsonResult {
                Data = new { status = status }
            });
        }