Esempio n. 1
0
        public List <EventBasicInfo> GetAllEvents()
        {
            var listEvent = new List <EventBasicInfo>();

            try
            {
                List <int> IdList;
                using (var db = new Ws_DataContext())
                {
                    IdList = db.Events.Select(x => x.EventID).ToList();
                }

                using (var db = new EventDAL())
                {
                    foreach (int eventId in IdList)
                    {
                        EventBasicInfo eventBasic = db.GetFullEventBasicInformation(eventId);
                        listEvent.Add(eventBasic);
                    }
                }
            }
            catch (Exception)
            {
                //throw;
            }

            return(listEvent);
        }
Esempio n. 2
0
        //public List<DonationDAL> GetDonationHistoryOfUser(int userId)
        //{

        //}

        public DonationDTO GetFullInformationOfDonation(int donationId)
        {
            DonationDTO currentDonation = new DonationDTO();

            try
            {
                Donation donation;
                string   userName     = "";
                string   userImageUrl = "";
                using (var db = new Ws_DataContext())
                {
                    donation = db.Donations.FirstOrDefault(x => x.DonationId == donationId);
                    var wsUser = db.Ws_User.FirstOrDefault(x => x.UserID == donation.UserId);
                    if (wsUser != null)
                    {
                        userName = wsUser.UserName;
                    }

                    var userInformation = db.User_Information.FirstOrDefault(x => x.UserID == donation.UserId);
                    if (userInformation != null)
                    {
                        userImageUrl = userInformation.ProfileImage;
                    }
                }

                using (var db = new EventDAL())
                {
                    currentDonation.EventBasicInformation = db.GetFullEventBasicInformation(donation.EventId);
                }

                currentDonation.DonationId   = donation.DonationId;
                currentDonation.UserId       = donation.UserId;
                currentDonation.UserName     = userName;
                currentDonation.UserImageUrl = userImageUrl;
                currentDonation.EventId      = donation.EventId;
                currentDonation.TradeCode    = donation.TradeCode;
                currentDonation.DonatedMoney = donation.DonatedMoney;
                currentDonation.Content      = donation.Content;
                currentDonation.DonatedDate  = donation.DonatedDate.ToString("hh:mm:ss dd/MM/yy");
                currentDonation.IsPublic     = donation.IsPublic;
            }
            catch (Exception)
            {
                //throw;
            }
            return(currentDonation);
        }