Exemplo n.º 1
0
        // GET api/values/5
        public IHttpActionResult Get()
        {
            ApplicationUser user = UserManager.FindById(User.Identity.GetUserId());

            var appointments = _appDb.Appointments
                               .Where(app => app.User.Id == user.Id).ToList();

            if (_appDb.Appointments.Where(app => app.User.Id == user.Id) == null)
            {
                return(null);
            }
            else
            {
                var apptsPerPerson = new AppointmentsPerPersonModel
                {
                    UserName = user.FirstName + " " + user.LastName
                };

                foreach (Appointment app in appointments)
                {
                    var appView = new AppointmentViewModel
                    {
                        ApptDate = DTHelp.ParseDate(app.DateAndTime),
                        Time     = DTHelp.ParseTime(app.DateAndTime),
                        Notes    = app.Notes
                    };

                    apptsPerPerson.Appointments.Add(appView);
                }

                return(Ok(apptsPerPerson));
            }
        }
Exemplo n.º 2
0
        public IHttpActionResult GetAll()
        {
            var details = new List <AppointmentDetails>();

            ApplicationUser user = UserManager.FindById(User.Identity.GetUserId());

            if (_appDb.Appointments == null)
            {
                return(null);
            }
            else
            {
                var appointments = _appDb.Appointments.ToList();

                foreach (Appointment app in appointments)
                {
                    var appDetails = new AppointmentDetails
                    {
                        UserName = app.User.FirstName + " " + app.User.LastName,
                        Date     = DTHelp.ParseDate(app.DateAndTime),
                        Time     = DTHelp.ParseTime(app.DateAndTime),
                        Notes    = app.Notes
                    };

                    details.Add(appDetails);
                }

                return(Ok(details));
            }
        }