Example #1
0
        public async Task <ActionResult <List <NotificationDTO> > > GetNotification(string userId, DateTime startDate)
        {
            List <NotificationDTO> dtoList = new List <NotificationDTO>();

            DateTime compareDate = new DateTime(startDate.Year, startDate.Month, startDate.Day);
            var      notiList    = await NB.GetNotification(userId, compareDate);

            foreach (var noti in notiList)
            {
                var fromUser = await UB.GetUserDetails(noti.FromUserId);

                var ToUser = await UB.GetUserDetails(noti.ToUserId);

                NotificationDTO dto = new NotificationDTO();
                dto = mapper.Map <NotificationDTO>(noti);
                dto.FromUserName = fromUser.FirstName + " " + fromUser.LastName;
                dto.ToUserName   = ToUser.FirstName + " " + ToUser.LastName;
                dto.ItemTitle    = noti.Item.Name;
                dtoList.Add(dto);
            }

            return(dtoList);
        }