Ejemplo n.º 1
0
        /// <summary>
        ///     Termine eines Shops holen
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="date"></param>
        /// <returns></returns>
        public async Task <ResultData <List <ExMeeting> > > GetMyMeetingsForDate(int userId, DateTime date)
        {
            var request = new ExGetMeetingsForDateRequest
            {
                Date           = date,
                UserId         = userId,
                ShowTakenSlots = true
            };

            return(await _wap.Post <List <ExMeeting> >("GetMyMeetingsForDate", request));
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     Termine eines Shops holen
        /// </summary>
        /// <param name="locationId"></param>
        /// <param name="date"></param>
        /// <param name="showTakenSlots"></param>
        /// <returns></returns>
        public async Task <ResultData <List <ExMeeting> > > GetMeetingsForDate(int locationId, DateTime date, bool showTakenSlots = false)
        {
            var request = new ExGetMeetingsForDateRequest
            {
                Date           = date,
                LocationId     = locationId,
                ShowTakenSlots = showTakenSlots,
            };

            return(await _wap.Post <List <ExMeeting> >("GetMeetingsForDate", request));
        }
Ejemplo n.º 3
0
        public async Task <List <ExMeeting> > GetMyMeetingsForDateWeb([FromBody] ExGetMeetingsForDateRequest request)
        {
            if (!request.UserId.HasValue)
            {
                HttpContext.Response.StatusCode = BadRequest().StatusCode;
                return(new List <ExMeeting>());
            }

            if (request.CheckPassword != WebAppSettings.CheckPassword)
            {
                HttpContext.Response.StatusCode = Unauthorized().StatusCode;
                return(new List <ExMeeting>());
            }

            return(await GetMyMeetingsForDateInternal(request));
        }
Ejemplo n.º 4
0
        public async Task <List <ExMeeting> > GetMyMeetingsForDate([FromBody] ExGetMeetingsForDateRequest request)
        {
            if (!request.UserId.HasValue)
            {
                HttpContext.Response.StatusCode = BadRequest().StatusCode;
                return(new List <ExMeeting>());
            }

            ClaimsIdentity identity = null;

            try
            {
                identity = HttpContext.User.Identity as ClaimsIdentity;
            }
            catch (Exception e)
            {
                Logging.Log.LogError("No Claims identity");
            }

            if (identity != null)
            {
                var claims = identity.Claims;

                if (!identity.HasClaim(c => c.Type == "UserID"))
                {
                    HttpContext.Response.StatusCode = Unauthorized().StatusCode;
                    return(new List <ExMeeting>());
                }

                var userId = identity.HasClaim(c => c.Type == "UserID")
                    ? identity.FindFirst("UserID").Value
                    : "a"; //BENUTZER ID

                if (request.UserId.Value.ToString() != userId)
                {
                    HttpContext.Response.StatusCode = Unauthorized().StatusCode;
                    return(new List <ExMeeting>());
                }
            }
            else
            {
                HttpContext.Response.StatusCode = Unauthorized().StatusCode;
                return(new List <ExMeeting>());
            }

            return(await GetMyMeetingsForDateInternal(request));
        }
Ejemplo n.º 5
0
        public async Task <List <ExMeeting> > GetMeetingsForDate([FromBody] ExGetMeetingsForDateRequest request)
        {
            if (!request.LocationId.HasValue)
            {
                return(new List <ExMeeting>());
            }

            var res = MeetingSlots.GetSlots(request.LocationId.Value, request.Date);

            if (!request.ShowTakenSlots)
            {
                // Nur freie Termine
                res = res.Where(x => x.Id < 0).ToList();
            }

            return(res.OrderBy(x => x.Start).ToList());
        }
Ejemplo n.º 6
0
        /// <summary>
        ///     Termine eines Users für einen Tag holen
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        private async Task <List <ExMeeting> > GetMyMeetingsForDateInternal(ExGetMeetingsForDateRequest request)
        {
            using (var db = new Db())
            {
                var res = new List <ExMeeting>();

                var meetings = db.TblAppointments
                               .Include(x => x.Employee)
                               .Include(x => x.Employee).ThenInclude(x => x.Store)
                               .Include(x => x.Employee).ThenInclude(x => x.TblLocationEmployee)
                               .AsNoTracking()
                               .Where(x => x.UserId == request.UserId.Value &&
                                      !x.Canceled &&
                                      (x.ValidFrom.Date == request.Date.Date || x.ValidTo.Date == request.Date.Date));

                foreach (var dbMeeting in meetings)
                {
                    var meeting = new ExMeeting
                    {
                        Id = dbMeeting.Id,

                        // TODO ShopId ist eigentlich auf Location und ein MA kann bei mehreren Locations sein, also beim Meeting Location auch dazu?
                        ShopId = dbMeeting.Employee?.TblLocationEmployee?.FirstOrDefault()?.TblLocationId ??
                                 dbMeeting.Employee?.StoreId ?? -1,

                        ShopName = dbMeeting.Employee?.Store?.CompanyName ?? "-",
                        Staff    = Staff.GetExStaff(dbMeeting.Employee),
                        UserId   = dbMeeting.UserId,
                        Start    = dbMeeting.ValidFrom,
                        End      = dbMeeting.ValidTo,
                    };

                    res.Add(meeting);
                }

                return(res.OrderBy(x => x.Start).ToList());
            }
        }
Ejemplo n.º 7
0
 /// <summary>
 ///     Termine eines Users holen
 /// </summary>
 /// <param name="request"></param>
 /// <returns></returns>
 public async Task <ResultData <List <ExMeeting> > > GetMyMeetingsForDateWeb(ExGetMeetingsForDateRequest request)
 {
     return(await _wap.Post <List <ExMeeting> >("GetMyMeetingsForDateWeb", request));
 }