コード例 #1
0
 public List <Event> getAllEvents()
 {
     using (var context = new EventsDBEntities())
     {
         return(context.Events.ToList());
     }
 }
コード例 #2
0
 public List <Event> myEvents(string username)
 {
     using (var context = new EventsDBEntities())
     {
         int id = getUserId(username);
         return(context.Events.Where(allEvents => allEvents.UserId == id).ToList());
     }
 }
コード例 #3
0
 public void addComment(Comment comment)
 {
     using (var context = new EventsDBEntities())
     {
         context.Comments.Add(comment);
         context.SaveChanges();
     }
 }
コード例 #4
0
ファイル: HomeController.cs プロジェクト: ELMAHDI-AR/Demo
        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
                });
            }
        }
コード例 #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);
            }
        }
コード例 #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);
            }
        }
コード例 #7
0
 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);
     }
 }
コード例 #8
0
 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);
     };
 }
コード例 #9
0
 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);
     }
 }
コード例 #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);
     }
 }
コード例 #11
0
        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);
            };
        }
コード例 #12
0
 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();
     }
 }
コード例 #13
0
        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);
            }
        }
コード例 #14
0
ファイル: HomeController.cs プロジェクト: ELMAHDI-AR/Demo
        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 }
            });
        }
コード例 #15
0
ファイル: HomeController.cs プロジェクト: ELMAHDI-AR/Demo
        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 }
            });
        }