예제 #1
0
        public static TaskListModel GetTasksListByDate(DateTime date, User currentUser)
        {
            BYEntities db = new BYEntities();
            List<Task> tempUncTasks = db.Tasks.Where(x => db.Calendars.Any(
                    y => EntityFunctions.TruncateTime(y.Date) == date
                    && x.Id == y.TaskId
                    && y.UserId == currentUser.Id
                    && y.TaskCompleted == false)).ToList();

            List<TasksModel> uncompletedTasks = new List<TasksModel>();
            foreach (Task tsk in tempUncTasks)
            {
                uncompletedTasks.Add(new TasksModel(tsk));
            }

            List<Task> tempCompTasks = db.Tasks.Where(x => db.Calendars.Any(
                y => EntityFunctions.TruncateTime(y.Date) == date
                && x.Id == y.TaskId
                && y.UserId == currentUser.Id
                && y.TaskCompleted == true)).ToList();

            List<TasksModel> completedTasks = new List<TasksModel>();
            foreach (Task tsk in tempCompTasks)
            {
                completedTasks.Add(new TasksModel(tsk));
            }
            return new TaskListModel(completedTasks, uncompletedTasks);
        }
예제 #2
0
 //used for edit user info
 public UsersModel(string sessionId, string firstName, string lastName, string email)
 {
     BYEntities db = new BYEntities();
     this.Username = db.Users.SingleOrDefault(x => x.SessionId == sessionId).Username;
     this.AuthCode = db.Users.SingleOrDefault(x => x.SessionId == sessionId).AuthCode;
     this.SessionId = sessionId;
     this.DateRegistered = db.Users.SingleOrDefault(x => x.SessionId == sessionId).DateRegistered;
     this.LastLogin = db.Users.SingleOrDefault(x => x.SessionId == sessionId).LastLogin;
     this.FirstName = firstName;
     this.LastName = lastName;
     this.Email = email;
 }
예제 #3
0
 public HttpResponseMessage EditUserInfo(JObject usr)
 {
     var msg = PerformOperation(() =>
     {
         BYEntities db = new BYEntities();
         string sessionId = usr["sessionId"].Value<string>();
         ValidateSessionId(sessionId);
         var user = db.Users.SingleOrDefault(x => x.SessionId == sessionId);
         FirstNameValidation(usr["firstName"].Value<string>());
         LastNameValidation(usr["lastName"].Value<string>());
         EmailValidation(usr["email"].Value<string>());
         user.FirstName = usr["firstName"].Value<string>();
         user.LastName = usr["lastName"].Value<string>();
         user.Email = usr["email"].Value<string>();
         db.SaveChanges();
         return new UserSession(usr["sessionId"].Value<string>());
     });
     return msg;
 }