Exemple #1
0
        public HttpResponseMessage CheckMeetings()

        {
            VolunteerMatchDbContext db = new VolunteerMatchDbContext();

            /* Test();*/
            try
            {
                var meetings = db.Meetings.ToList();
                foreach (var meeting in meetings)
                {
                    if (CheckIfShouldSendPush((int)meeting.meetingUnixDate))
                    {
                        Member firstMember = db.Members.Where(x => x.id == meeting.firstMemberId).FirstOrDefault();
                        SendPush(firstMember.notificationId, firstMember.fullName);
                        Member secondMember = db.Members.Where(x => x.id == meeting.secondMemberId).FirstOrDefault();
                        SendPush(secondMember.notificationId, secondMember.fullName);
                        //Add Notification To DB

                        Notification firstNotification = new Notification()
                        {
                            memberId         = firstMember.id,
                            notificationType = "meetingCheck",
                            otherMemberId    = secondMember.id,
                            notificationText = $"Did you eventually meet {secondMember.fullName} for {meeting.meetingEventTitle}?",
                            unixdate         = (int)DateTimeOffset.Now.ToUnixTimeSeconds(),
                        };
                        Notification secondNotification = new Notification()
                        {
                            memberId         = secondMember.id,
                            notificationType = "meetingCheck",
                            otherMemberId    = firstMember.id,
                            notificationText = $"Did you eventually meet {firstMember.fullName} for {meeting.meetingEventTitle}?",
                            unixdate         = (int)DateTimeOffset.Now.ToUnixTimeSeconds(),
                        };


                        db.Notifications.Add(firstNotification);
                        db.Notifications.Add(secondNotification);



                        //DELETE MEETING FROM DB and adding notification to db
                        Meeting meetingTORemove = db.Meetings.Where(x => x.id == meeting.id).FirstOrDefault();
                        db.Meetings.Remove(meetingTORemove);
                    }
                }
                db.SaveChanges();
                return(Request.CreateResponse(HttpStatusCode.OK, "Success"));
            }
            catch (Exception e)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, e.Message));

                throw;
            }

            /* long now = DateTimeOffset.Now.ToUnixTimeSeconds();*/
            // here i will check all upcoimg meetings - if meetings passed 3 days - i will sendpush() for both users - and add notification of meetingCheck to both users
        }
Exemple #2
0
        public HttpResponseMessage getChatRoomId(int memberId, int otherMemberId)
        {
            VolunteerMatchDbContext db = new VolunteerMatchDbContext();

            try
            {
                var chats = db.ChatHistories.Where(x => (x.fromMemberId == memberId && x.toMemberId == otherMemberId) || (x.fromMemberId == otherMemberId && x.toMemberId == memberId)).Select(x => new ChatRoomDTO()
                {
                    chatRoomId       = (int)x.chatRoomId,
                    otherMemberId    = otherMemberId,
                    otherMemberName  = db.Members.Where(z => z.id == otherMemberId).Select(y => y.fullName).FirstOrDefault(),
                    otherMemberImage = db.Members.Where(z => z.id == otherMemberId).Select(y => y.pictureUrl).FirstOrDefault()
                }).FirstOrDefault();

                if (chats == null)
                {
                    ChatRoomDTO newChatRoom = new ChatRoomDTO();
                    newChatRoom.otherMemberId    = otherMemberId;
                    newChatRoom.otherMemberName  = db.Members.Where(z => z.id == otherMemberId).Select(y => y.fullName).FirstOrDefault();
                    newChatRoom.otherMemberImage = db.Members.Where(z => z.id == otherMemberId).Select(y => y.pictureUrl).FirstOrDefault();
                    newChatRoom.chatRoomId       = (int)db.ChatHistories.Max(x => x.chatRoomId) + 1;
                    return(Request.CreateResponse(HttpStatusCode.OK, newChatRoom));
                }
                return(Request.CreateResponse(HttpStatusCode.OK, chats));
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message));
            }
        }
Exemple #3
0
        public static void Test()
        {
            VolunteerMatchDbContext db = new VolunteerMatchDbContext();

            try
            {
                Notification notificationn = new Notification()
                {
                    memberId         = 157,
                    otherMemberId    = 2,
                    notificationText = "nfrom server",
                    notificationType = "n",
                    unixdate         = 1
                };
                db.Notifications.Add(notificationn);

                db.SaveChanges();
            }
            catch (Exception e)
            {
                SendPushCatch(e.InnerException.ToString());
            }

            /* db.SaveChangesAsync();*/
        }
Exemple #4
0
        public HttpResponseMessage Mail()
        {
            VolunteerMatchDbContext db = new VolunteerMatchDbContext();

            try
            {
                SmtpClient client = new SmtpClient("smtp.mail.yahoo.com", 587)
                {
                    Credentials = new NetworkCredential("*****@*****.**", "jocmheavcewlyclt"),
                    EnableSsl   = true,
                    //add to member blocked == true
                    //in client - while register or logn check if member is bloked - if block show alert else contuniue regular
                    //
                };
                client.Send("*****@*****.**", "*****@*****.**", "Volunteerz - You got blocked", "dear Alan, since you bailed 3 times from meeting we have to block your account");
                return(Request.CreateResponse(HttpStatusCode.OK, "SEND MAIL"));
            }
            catch (Exception e)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, e.Message));
            }


            //Console.WriteLine("Sent");
            //Console.ReadLine();
        }
Exemple #5
0
        public HttpResponseMessage createMeeting(int chatRoomId)
        {
            VolunteerMatchDbContext db = new VolunteerMatchDbContext();

            try
            {
                var         chatMassages = db.ChatHistories.Where(x => x.chatRoomId == chatRoomId).ToList();
                ChatHistory meetingMsg   = chatMassages.Where(x => x.meetingMsg == true).FirstOrDefault();
                Meeting     meeting      = new Meeting()
                {
                    firstMemberId        = (int)meetingMsg.fromMemberId,
                    secondMemberId       = (int)meetingMsg.toMemberId,
                    meetingEventTitle    = meetingMsg.meetingEventTitle,
                    meetingUnixDate      = meetingMsg.meetingUnixDate,
                    didHappen            = false,
                    meetingDateLabel     = meetingMsg.meetingDateLabel,
                    meetingTimeLabel     = meetingMsg.meetingTimeLabel,
                    meetingLocationLabel = meetingMsg.meetingLocationLabel,
                    didPushSent          = false,
                };
                db.Meetings.Add(meeting);
                db.ChatHistories.Remove(meetingMsg);
                db.SaveChanges();



                return(Request.CreateResponse(HttpStatusCode.OK, "Meeting saved in DB!"));
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message));
            }
        }
Exemple #6
0
        public HttpResponseMessage getChatHistory(int chatRoomId, int memberId)
        {
            VolunteerMatchDbContext db = new VolunteerMatchDbContext();

            try
            {
                var chats = db.ChatHistories.Where(x => x.chatRoomId == chatRoomId).Select(x => new ChatHistoryDTO()
                {
                    messageId    = x.messageId,
                    datetime     = (int)x.datetime,
                    fromMemberId = (int)x.fromMemberId,
                    toMemberId   = (int)x.toMemberId,
                    mine         = (x.fromMemberId == memberId),

                    //I need to verify this, maybe add another clause to receive both last recived and sent
                    text = x.text,
                    //This applies only if its a neeting msg
                    meetingMsg           = (bool)x.meetingMsg,
                    meetingDateLabel     = x.meetingDateLabel,
                    meetingEventTitle    = x.meetingEventTitle,
                    meetingUnixDate      = (int)x.meetingUnixDate,
                    meetingTimeLabel     = x.meetingTimeLabel,
                    meetingLocationLabel = x.meetingLocationLabel
                }).OrderBy(x => x.datetime).ThenBy(z => z.messageId).ToList();
                return(Request.CreateResponse(HttpStatusCode.OK, chats));
            }
            catch (DbEntityValidationException ex)
            {
                string errors = "";
                foreach (DbEntityValidationResult vr in ex.EntityValidationErrors)
                {
                    foreach (DbValidationError er in vr.ValidationErrors)
                    {
                        errors += $"PropertyName - {er.PropertyName }, Error {er.ErrorMessage} <br/>";
                    }
                }
                return(Request.CreateResponse(HttpStatusCode.BadRequest, errors));
            }
            catch (DbUpdateException ex)
            {
                DbUpdateException e      = (DbUpdateException)ex;
                string            errors = "";
                foreach (DbEntityEntry entry in e.Entries)
                {
                    errors += $"Error in entity - {entry.Entity.GetType().Name}, entity state - {entry.State} <br/>";

                    foreach (string prop in entry.CurrentValues.PropertyNames)
                    {
                        errors += $"for column - {prop}, value - {entry.CurrentValues[prop]} <br/>";
                    }
                    errors += "---------------";
                }

                return(Request.CreateResponse(HttpStatusCode.BadRequest, errors));
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message));
            }
        }
Exemple #7
0
        public HttpResponseMessage CheckIfMemberExists(MemberLoginDTO memberLogin)
        {
            VolunteerMatchDbContext db = new VolunteerMatchDbContext();

            try
            {
                Member member = db.Members.SingleOrDefault(x => x.email == memberLogin.email);
                if (member != null)
                {
                    var AuthorizedMemberDetails = db.FeedSettings.Where(x => x.memberId == member.id).Select(x => new AuthorizedMemberDetailsDTO
                    {
                        id                = member.id,
                        name              = member.fullName,
                        helpType          = x.memberType,
                        participantAge    = x.participantAgeRange,
                        participantGender = x.participantGender,
                        meetingLocation   = x.postLocation,
                        pictureUrl        = member.pictureUrl
                    });


                    return(Request.CreateResponse(HttpStatusCode.OK, AuthorizedMemberDetails));
                }



                return(Request.CreateResponse(HttpStatusCode.BadRequest, "User dosent exists"));
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, "General error"));
            }
        }
Exemple #8
0
        public HttpResponseMessage addNotification(NotificationDTO notificationDTO)
        {
            VolunteerMatchDbContext db = new VolunteerMatchDbContext();



            try
            {
                Notification notification = new Notification()
                {
                    memberId         = notificationDTO.memberId,
                    otherMemberId    = notificationDTO.otherMemberId,
                    notificationText = notificationDTO.notificationText,
                    notificationType = notificationDTO.notificationType,
                    unixdate         = notificationDTO.unixdate
                };
                db.Notifications.Add(notification);
                db.SaveChanges();

                return(Request.CreateResponse(HttpStatusCode.OK, "Notification Saved In DB"));
            }
            catch (Exception)
            {
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, "Unknown error occured"));
            }
        }
Exemple #9
0
        public HttpResponseMessage GetMembersBySearchWord(string searchWord)
        {
            VolunteerMatchDbContext db = new VolunteerMatchDbContext();

            try
            {
                var usersWIthSearchWord = db.Members.Where(x => x.fullName.Contains(searchWord)).ToList();
                List <ProfileDetailsDTO> usersToSend = new List <ProfileDetailsDTO>();
                foreach (Member m in usersWIthSearchWord)
                {
                    ProfileDetailsDTO profileDTO = new ProfileDetailsDTO()
                    {
                        fullName = m.fullName,

                        pictureUrl = m.pictureUrl,
                        memberId   = m.id
                    };
                    usersToSend.Add(profileDTO);
                }
                ;



                return(Request.CreateResponse(HttpStatusCode.OK, usersToSend));
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message));
            }
        }
Exemple #10
0
        public HttpResponseMessage AddReview(ReviewsDTO reviewsDTO)
        {
            VolunteerMatchDbContext db = new VolunteerMatchDbContext();

            DateTime now      = DateTime.Now;
            long     unixTime = ((DateTimeOffset)now).ToUnixTimeSeconds();

            try
            {
                Review review = new Review
                {
                    fromMemberId = reviewsDTO.fromMemberId,
                    memberId     = reviewsDTO.memberId,
                    text         = reviewsDTO.text,
                    url          = reviewsDTO.url,
                    stars        = reviewsDTO.stars,
                    date         = (int)unixTime
                };

                db.Reviews.Add(review);
                db.SaveChanges();
            }
            catch (DbEntityValidationException ex)
            {
                string errors = "";
                foreach (DbEntityValidationResult vr in ex.EntityValidationErrors)
                {
                    foreach (DbValidationError er in vr.ValidationErrors)
                    {
                        errors += $"PropertyName - {er.PropertyName }, Error {er.ErrorMessage} <br/>";
                    }
                }
                return(Request.CreateResponse(HttpStatusCode.BadRequest, errors));
            }
            catch (DbUpdateException ex)
            {
                DbUpdateException e      = (DbUpdateException)ex;
                string            errors = "";
                foreach (DbEntityEntry entry in e.Entries)
                {
                    errors += $"Error in entity - {entry.Entity.GetType().Name}, entity state - {entry.State} <br/>";

                    foreach (string prop in entry.CurrentValues.PropertyNames)
                    {
                        errors += $"for column - {prop}, value - {entry.CurrentValues[prop]} <br/>";
                    }
                    errors += "---------------";
                }

                return(Request.CreateResponse(HttpStatusCode.BadRequest, errors));
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message));
            }
            return(Request.CreateResponse(HttpStatusCode.OK, "Review added"));
        }
Exemple #11
0
        // GET api/<controller>
        public string Get()
        {
            VolunteerMatchDbContext db = new VolunteerMatchDbContext();

            Member    member    = db.Members.SingleOrDefault(x => x.fullName == "alan skverer");
            MemberDTO memberDTO = new MemberDTO();

            memberDTO.name = "My email address is: " + member.email;
            return(memberDTO.name);
        }
Exemple #12
0
        // GET api/<controller>
        public List <HobbiesDTO> Get()
        {
            VolunteerMatchDbContext db = new VolunteerMatchDbContext();

            return(db.Hobbies.Select(x => new HobbiesDTO()
            {
                id = x.id,
                name = x.name,
            }).ToList());
        }
Exemple #13
0
        public HttpResponseMessage UpdateFeedSettings(FeedSettingsDTO feedSettingsDTO, int userId)
        {
            VolunteerMatchDbContext db          = new VolunteerMatchDbContext();
            FeedSetting             feedSetting = db.FeedSettings.Where(x => x.memberId == userId).FirstOrDefault();

            try
            {
                feedSetting.memberType          = feedSettingsDTO.memberType;
                feedSetting.participantAgeRange = feedSettingsDTO.participantAgeRange;
                feedSetting.participantGender   = feedSettingsDTO.participantGender;
                feedSetting.postLocation        = feedSettingsDTO.postLocation;
                db.SaveChanges();
            }
            catch (DbEntityValidationException ex)
            {
                string errors = "";
                foreach (DbEntityValidationResult vr in ex.EntityValidationErrors)
                {
                    foreach (DbValidationError er in vr.ValidationErrors)
                    {
                        errors += $"PropertyName - {er.PropertyName }, Error {er.ErrorMessage} <br/>";
                    }
                }
                return(Request.CreateResponse(HttpStatusCode.BadRequest, errors));
            }
            catch (DbUpdateException ex)
            {
                DbUpdateException e      = (DbUpdateException)ex;
                string            errors = "";
                foreach (DbEntityEntry entry in e.Entries)
                {
                    errors += $"Error in entity - {entry.Entity.GetType().Name}, entity state - {entry.State} <br/>";

                    foreach (string prop in entry.CurrentValues.PropertyNames)
                    {
                        errors += $"for column - {prop}, value - {entry.CurrentValues[prop]} <br/>";
                    }
                    errors += "---------------";
                }

                return(Request.CreateResponse(HttpStatusCode.BadRequest, errors));
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message));
            }
            return(Request.CreateResponse(HttpStatusCode.OK, "Feed settings updated successfully!"));
        }
Exemple #14
0
        public HttpResponseMessage GetNotificationId(int memberId)
        {
            VolunteerMatchDbContext db = new VolunteerMatchDbContext();

            try
            {
                Member member             = db.Members.Where(x => x.id == memberId).FirstOrDefault();
                string pushNotificationId = member.notificationId;

                return(Request.CreateResponse(HttpStatusCode.OK, pushNotificationId));
            }
            catch (Exception)
            {
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, "Unknown error occured"));
            }
        }
Exemple #15
0
        public HttpResponseMessage DeleteNotification(int notificationId)
        {
            VolunteerMatchDbContext db = new VolunteerMatchDbContext();

            try
            {
                Notification notification = db.Notifications.Where(x => x.id == notificationId).FirstOrDefault();

                db.Notifications.Remove(notification);
                db.SaveChanges();
                return(Request.CreateResponse(HttpStatusCode.OK, "Notification Deleted"));
            }
            catch (Exception)
            {
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, "Unknown error occured"));
            }
        }
Exemple #16
0
        public HttpResponseMessage SetNotificationId(int memberId, string notificationId)
        {
            VolunteerMatchDbContext db = new VolunteerMatchDbContext();

            try
            {
                Member member = db.Members.Where(x => x.id == memberId).FirstOrDefault();
                member.notificationId = notificationId;
                db.SaveChanges();
            }
            catch (DbEntityValidationException ex)
            {
                string errors = "";
                foreach (DbEntityValidationResult vr in ex.EntityValidationErrors)
                {
                    foreach (DbValidationError er in vr.ValidationErrors)
                    {
                        errors += $"PropertyName - {er.PropertyName }, Error {er.ErrorMessage} <br/>";
                    }
                }
                return(Request.CreateResponse(HttpStatusCode.BadRequest, errors));
            }
            catch (DbUpdateException ex)
            {
                DbUpdateException e      = (DbUpdateException)ex;
                string            errors = "";
                foreach (DbEntityEntry entry in e.Entries)
                {
                    errors += $"Error in entity - {entry.Entity.GetType().Name}, entity state - {entry.State} <br/>";

                    foreach (string prop in entry.CurrentValues.PropertyNames)
                    {
                        errors += $"for column - {prop}, value - {entry.CurrentValues[prop]} <br/>";
                    }
                    errors += "---------------";
                }

                return(Request.CreateResponse(HttpStatusCode.BadRequest, errors));
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message));
            }
            return(Request.CreateResponse(HttpStatusCode.OK, "Notification ID Saved In DB"));
        }
Exemple #17
0
        public HttpResponseMessage DeleteMeetingMessage(int chatRoomId)
        {
            VolunteerMatchDbContext db = new VolunteerMatchDbContext();

            try
            {
                ChatHistory meetingMsgToDelete = db.ChatHistories.Where(x => x.chatRoomId == chatRoomId && x.meetingMsg == true).FirstOrDefault();
                db.ChatHistories.Remove(meetingMsgToDelete);
                db.SaveChanges();


                return(Request.CreateResponse(HttpStatusCode.OK, "Meeting msg deleted from DB"));
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message));
            }
        }
Exemple #18
0
        public HttpResponseMessage AddCurrentLocation(int memberId, double lat, double lng)
        {
            VolunteerMatchDbContext db = new VolunteerMatchDbContext();


            try
            {
                Member member = db.Members.Where(x => x.id == memberId).FirstOrDefault();
                member.lastLocationLat  = lat;
                member.lastLocationLong = lng;

                db.SaveChanges();

                return(Request.CreateResponse(HttpStatusCode.OK, "Current location updated"));
            }
            catch (Exception)
            {
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, "Unknown error occured"));
            }
        }
Exemple #19
0
        public HttpResponseMessage GetAllReviews(int memberId)
        {
            VolunteerMatchDbContext db      = new VolunteerMatchDbContext();
            List <ReviewsDTO>       reviews = db.Reviews.Where(x => x.memberId == memberId).Select(y => new ReviewsDTO
            {
                fromMemberId     = (int)y.fromMemberId,
                otherMemberImage = db.Members.Where(x => x.id == (int)y.fromMemberId).FirstOrDefault().pictureUrl,
                otherMemberName  = db.Members.Where(x => x.id == (int)y.fromMemberId).FirstOrDefault().fullName,
                text             = y.text,
                stars            = (int)y.stars,
                id = y.id
            }).ToList();

            try
            {
                return(Request.CreateResponse(HttpStatusCode.OK, reviews));
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message));
            }
        }
Exemple #20
0
        public HttpResponseMessage GetMemberLastLocation(int memberId)
        {
            VolunteerMatchDbContext db = new VolunteerMatchDbContext();



            try
            {
                Member member = db.Members.Where(x => x.id == memberId).FirstOrDefault();

                LongLatDTO longLatDTO = new LongLatDTO()
                {
                    lastLocationLat  = (double)member.lastLocationLat,
                    lastLocationLong = (double)member.lastLocationLong,
                };
                return(Request.CreateResponse(HttpStatusCode.OK, longLatDTO));
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message));
            }
        }
Exemple #21
0
        public HttpResponseMessage GetUpcomingMeetings(int memberId)
        {
            VolunteerMatchDbContext db = new VolunteerMatchDbContext();

            int today = (int)DateTimeOffset.Now.ToUnixTimeSeconds();

            try
            {
                List <MeetingDTO> upcomingMeetings = db.Meetings.Where
                                                         (x => x.firstMemberId == memberId && x.meetingUnixDate > today ||
                                                         x.secondMemberId == memberId && x.meetingUnixDate > today)
                                                     .Select(m => new MeetingDTO
                {
                    meetingDateLabel     = m.meetingDateLabel,
                    meetingEventTitle    = m.meetingEventTitle,
                    meetingLocationLabel = m.meetingLocationLabel,
                    meetingTimeLabel     = m.meetingTimeLabel,
                    otherMemberId        = m.secondMemberId == memberId ? m.firstMemberId : m.secondMemberId,
                    meetingUnixDate      = (int)m.meetingUnixDate
                }).ToList();

                foreach (MeetingDTO meetingDetails in upcomingMeetings)
                {
                    string otherMemberImageUrl = db.Members.Where(x => x.id == meetingDetails.otherMemberId).Select(y => y.pictureUrl).FirstOrDefault();
                    string otherMemberName     = db.Members.Where(x => x.id == meetingDetails.otherMemberId).Select(y => y.fullName).FirstOrDefault();
                    meetingDetails.otherMemberImage = otherMemberImageUrl;
                    meetingDetails.otherMemberName  = otherMemberName;
                }

                List <MeetingDTO> sortedMeetingsList = upcomingMeetings.OrderBy(o => o.meetingUnixDate).ToList();

                return(Request.CreateResponse(HttpStatusCode.OK, sortedMeetingsList));
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message));
            }
        }
Exemple #22
0
        public HttpResponseMessage markLastMassageRead(int chatRoomId, int memberId)
        {
            VolunteerMatchDbContext db = new VolunteerMatchDbContext();

            try
            {
                var         messagesIds         = db.ChatHistories.Where(x => x.chatRoomId == chatRoomId).Select(y => y.messageId).ToList();
                int         lastMessageInRoomId = messagesIds.Last();
                ChatHistory lastMessageInRoom   = db.ChatHistories.Where(x => x.messageId == lastMessageInRoomId).FirstOrDefault();
                if (lastMessageInRoom.fromMemberId != memberId && lastMessageInRoom.markAsRead == false)
                {
                    lastMessageInRoom.markAsRead = true;
                    db.SaveChanges();
                    return(Request.CreateResponse(HttpStatusCode.OK, "Message marked as read"));
                }


                return(Request.CreateResponse(HttpStatusCode.OK, $"Last message is of user {memberId} or message was read already"));
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message));
            }
        }
Exemple #23
0
        public HttpResponseMessage getNotifications(int memberId)
        {
            VolunteerMatchDbContext db = new VolunteerMatchDbContext();



            try
            {
                List <NotificationDTO> notifications = db.Notifications.Where(x => x.memberId == memberId).Select(y => new NotificationDTO()
                {
                    memberId         = memberId,
                    otherMemberId    = (int)y.otherMemberId,
                    notificationText = y.notificationText,
                    notificationType = y.notificationType,
                    notificationId   = y.id,
                    unixdate         = (int)y.unixdate
                }).ToList();

                foreach (NotificationDTO notification in notifications)
                {
                    string memberImage = db.Members.Where(x => x.id == notification.otherMemberId).Select(y => y.pictureUrl).FirstOrDefault();
                    string memberName  = db.Members.Where(x => x.id == notification.otherMemberId).Select(y => y.fullName).FirstOrDefault();

                    notification.otherMemberName  = memberName;
                    notification.otherMemberImage = memberImage;



                    int lastUnixDate = notification.unixdate;

                    DateTime dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
                    dtDateTime = dtDateTime.AddSeconds(lastUnixDate).ToLocalTime();

                    //Checking if last notification was sent over the last 24 hrs
                    string   notificationDate;
                    DateTime now = DateTime.Now;
                    if (dtDateTime > now.AddHours(-24) && dtDateTime <= now)
                    {
                        decimal hours        = Math.Floor((decimal)(now - dtDateTime).TotalHours);
                        int     hoursDiffInt = (int)hours;
                        if (hoursDiffInt == 0)
                        {
                            notificationDate = (now - dtDateTime).Minutes.ToString();
                            if (notificationDate == "0")
                            {
                                notificationDate = "Now";
                            }
                            else
                            {
                                notificationDate += " min ago";
                            }
                        }
                        else
                        {
                            notificationDate = $"{hoursDiffInt}h ago";
                        }
                    }
                    else
                    {
                        string year  = dtDateTime.Year.ToString();
                        string month = dtDateTime.Month.ToString();
                        string day   = dtDateTime.Day.ToString();
                        notificationDate = $"{day}/{month}/{year}";
                    };

                    notification.notificationDate = notificationDate;
                }


                List <NotificationDTO> sortedNotificationList = notifications.OrderByDescending(o => o.unixdate).ToList();

                return(Request.CreateResponse(HttpStatusCode.OK, sortedNotificationList));
            }
            catch (Exception)
            {
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, "Unknown error occured"));
            }
        }
Exemple #24
0
        public HttpResponseMessage Register(MemberSignupDTO memberSignupDTO)
        {
            VolunteerMatchDbContext db = new VolunteerMatchDbContext();

            try
            {
                Member member = new Member();
                member.email            = memberSignupDTO.email;
                member.city             = memberSignupDTO.city;
                member.password         = memberSignupDTO.password;
                member.fullName         = memberSignupDTO.fullName;
                member.pictureUrl       = memberSignupDTO.pictureUrl;
                member.occupation       = memberSignupDTO.occupation;
                member.gender           = memberSignupDTO.gender;
                member.biography        = memberSignupDTO.bio;
                member.dateOfBirth      = memberSignupDTO.dateOfBirth;
                member.lastLocationLat  = 0;
                member.lastLocationLong = 0;


                db.Members.Add(member);
                db.SaveChanges();
                FeedSetting feedSetting = new FeedSetting
                {
                    memberId            = member.id,
                    memberType          = memberSignupDTO.feedSettings.memberType,
                    participantAgeRange = memberSignupDTO.feedSettings.participantAgeRange,
                    participantGender   = memberSignupDTO.feedSettings.participantGender,
                    postLocation        = memberSignupDTO.feedSettings.postLocation
                };
                db.FeedSettings.Add(feedSetting);

                foreach (HobbiesDTO hobby in memberSignupDTO.hobbies)
                {
                    MembersHobby hobbies = new MembersHobby();
                    hobbies.hobbyId  = hobby.id;
                    hobbies.memberId = member.id;
                    db.MembersHobbies.Add(hobbies);
                }


                db.SaveChanges();

                AuthorizedMemberDetailsDTO authorizedMemberDetailsDTO = new AuthorizedMemberDetailsDTO()
                {
                    id                = member.id,
                    name              = member.fullName,
                    participantAge    = memberSignupDTO.feedSettings.participantAgeRange,
                    participantGender = memberSignupDTO.feedSettings.participantGender,
                    helpType          = memberSignupDTO.feedSettings.memberType,
                    meetingLocation   = memberSignupDTO.feedSettings.postLocation,
                    pictureUrl        = member.pictureUrl
                };

                return(Request.CreateResponse(HttpStatusCode.OK, authorizedMemberDetailsDTO));
            }
            catch (DbEntityValidationException ex)
            {
                string errors = "";
                foreach (DbEntityValidationResult vr in ex.EntityValidationErrors)
                {
                    foreach (DbValidationError er in vr.ValidationErrors)
                    {
                        errors += $"PropertyName - {er.PropertyName }, Error {er.ErrorMessage} <br/>";
                    }
                }
                return(Request.CreateResponse(HttpStatusCode.BadRequest, errors));
            }
            catch (DbUpdateException ex)
            {
                DbUpdateException e      = (DbUpdateException)ex;
                string            errors = "";
                foreach (DbEntityEntry entry in e.Entries)
                {
                    errors += $"Error in entity - {entry.Entity.GetType().Name}, entity state - {entry.State} <br/>";

                    foreach (string prop in entry.CurrentValues.PropertyNames)
                    {
                        errors += $"for column - {prop}, value - {entry.CurrentValues[prop]} <br/>";
                    }
                    errors += "---------------";
                }

                return(Request.CreateResponse(HttpStatusCode.BadRequest, errors));
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message));
            }
        }
Exemple #25
0
        public HttpResponseMessage UpdateProfile(ProfileDetailsDTO profileDetailsDTO, int userId)
        {
            VolunteerMatchDbContext db = new VolunteerMatchDbContext();
            Member member = db.Members.Where(x => x.id == userId).FirstOrDefault();

            try
            {
                if (profileDetailsDTO.unixDate == null)
                {
                    member.city       = profileDetailsDTO.city;
                    member.biography  = profileDetailsDTO.bio;
                    member.occupation = profileDetailsDTO.occupation;
                    member.gender     = profileDetailsDTO.gender;
                    member.pictureUrl = profileDetailsDTO.pictureUrl;
                }
                else
                {
                    member.city        = profileDetailsDTO.city;
                    member.biography   = profileDetailsDTO.bio;
                    member.occupation  = profileDetailsDTO.occupation;
                    member.gender      = profileDetailsDTO.gender;
                    member.pictureUrl  = profileDetailsDTO.pictureUrl;
                    member.dateOfBirth = profileDetailsDTO.unixDate;
                }

                if (profileDetailsDTO.hobbies != null)
                {
                    foreach (MembersHobby hobby in db.MembersHobbies.Where(x => x.memberId == userId))
                    {
                        MembersHobby membersHobby = hobby;
                        db.MembersHobbies.Remove(membersHobby);
                    }

                    foreach (HobbiesDTO hobby in profileDetailsDTO.hobbies)
                    {
                        MembersHobby hobbies = new MembersHobby();
                        hobbies.hobbyId  = hobby.id;
                        hobbies.memberId = member.id;
                        db.MembersHobbies.Add(hobbies);
                    }
                }
                db.SaveChanges();
            }

            catch (DbEntityValidationException ex)
            {
                string errors = "";
                foreach (DbEntityValidationResult vr in ex.EntityValidationErrors)
                {
                    foreach (DbValidationError er in vr.ValidationErrors)
                    {
                        errors += $"PropertyName - {er.PropertyName }, Error {er.ErrorMessage} <br/>";
                    }
                }
                return(Request.CreateResponse(HttpStatusCode.BadRequest, errors));
            }
            catch (DbUpdateException ex)
            {
                DbUpdateException e      = (DbUpdateException)ex;
                string            errors = "";
                foreach (DbEntityEntry entry in e.Entries)
                {
                    errors += $"Error in entity - {entry.Entity.GetType().Name}, entity state - {entry.State} <br/>";

                    foreach (string prop in entry.CurrentValues.PropertyNames)
                    {
                        errors += $"for column - {prop}, value - {entry.CurrentValues[prop]} <br/>";
                    }
                    errors += "---------------";
                }

                return(Request.CreateResponse(HttpStatusCode.BadRequest, errors));
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message));
            }

            return(Request.CreateResponse(HttpStatusCode.OK, "Profile updated successfully"));
        }
Exemple #26
0
        public HttpResponseMessage GetMyProfile(int id)
        {
            VolunteerMatchDbContext db = new VolunteerMatchDbContext();

            try
            {
                Member   member          = db.Members.SingleOrDefault(x => x.id == id);
                int      unixDateOfBirth = (int)member.dateOfBirth;
                DateTime dtDateTime      = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
                dtDateTime = dtDateTime.AddSeconds(unixDateOfBirth).ToLocalTime();
                var today = DateTime.Today;
                // Calculate the age.
                int age = today.Year - dtDateTime.Year;
                // Go back to the year in which the person was born in case of a leap year
                if (dtDateTime.Date > today.AddYears(-age))
                {
                    age--;
                }
                string dateOfBirth      = dtDateTime.ToString();
                string dateOfBirthLabel = dateOfBirth.Substring(0, dateOfBirth.IndexOf(" "));



                ProfileDetailsDTO profileDetailsDTO = new ProfileDetailsDTO()
                {
                    pictureUrl  = member.pictureUrl,
                    fullName    = member.fullName,
                    age         = age,
                    city        = member.city,
                    occupation  = member.occupation,
                    bio         = member.biography,
                    gender      = member.gender,
                    dateOfBirth = dateOfBirthLabel,


                    hobbies = db.MembersHobbies.Where(h => h.memberId == member.id).Select(z => new HobbiesDTO
                    {
                        name = z.Hobby.name
                    }).ToList()
                };

                var ratings = db.Reviews.Where(x => x.memberId == id).ToList();

                double rating       = 0;
                double ratingSum    = 0;
                int    numOfRatings = ratings.Count();

                if (ratings.Count() > 0)
                {
                    foreach (var r in ratings)
                    {
                        ratingSum += (int)r.stars;
                    }
                    ;

                    rating = ratingSum / (double)ratings.Count();
                    rating = Math.Round(rating, 1);
                    profileDetailsDTO.rating       = rating;
                    profileDetailsDTO.reviewsCount = ratings.Count();

                    //CHECK IF GOLD MEMBER

                    if (ratings.Count() >= 5 && rating > 4)
                    {
                        profileDetailsDTO.goldMember = true;
                    }
                    else
                    {
                        profileDetailsDTO.goldMember = false;
                    }
                }



                return(Request.CreateResponse(HttpStatusCode.OK, profileDetailsDTO));
                /*       return Request.CreateResponse(HttpStatusCode.OK, rating);*/
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message));
            }
        }
Exemple #27
0
        public HttpResponseMessage getRoomChats(int memberId)
        {
            VolunteerMatchDbContext db = new VolunteerMatchDbContext();

            try
            {
                var                allChatRoomsId      = db.ChatHistories.Where(x => x.fromMemberId == memberId || x.toMemberId == memberId).Select(y => y.chatRoomId).ToList();
                List <int>         relevantChatRoomsId = new List <int>();
                List <ChatRoomDTO> chatRooms           = new List <ChatRoomDTO>();

                foreach (int chatRoomId in allChatRoomsId)
                {
                    if (!relevantChatRoomsId.Contains(chatRoomId))
                    {
                        relevantChatRoomsId.Add(chatRoomId);
                    }
                }

                foreach (var chatRoomId in relevantChatRoomsId)
                {
                    int firstMemberId  = (int)db.ChatHistories.Where(x => x.chatRoomId == chatRoomId).Select(y => y.fromMemberId).FirstOrDefault();
                    int SecondMemberId = (int)db.ChatHistories.Where(x => x.chatRoomId == chatRoomId).Select(y => y.toMemberId).FirstOrDefault();
                    int otherMemberId;
                    if (firstMemberId == memberId)
                    {
                        otherMemberId = SecondMemberId;
                    }
                    else
                    {
                        otherMemberId = firstMemberId;
                    };

                    string      otherMemberName  = db.Members.Where(x => x.id == otherMemberId).Select(y => y.fullName).FirstOrDefault();
                    string      otherMemberImage = db.Members.Where(x => x.id == otherMemberId).Select(y => y.pictureUrl).FirstOrDefault();
                    ChatHistory chatHistory      = new ChatHistory();

                    //CHECK IF CAN BE OPTIMIZED
                    var chat = db.ChatHistories.Where(x => x.chatRoomId == chatRoomId).Select(y => y.text).ToList();

                    var    chatDate                = db.ChatHistories.Where(x => x.chatRoomId == chatRoomId).Select(y => y.datetime).ToList();
                    int    numOfMassages           = chat.Count();
                    string lastSentence            = chat[numOfMassages - 1];
                    var    chatIds                 = db.ChatHistories.Where(x => x.chatRoomId == chatRoomId).Select(y => y.fromMemberId).ToList();
                    int    lastMessageSenderId     = (int)chatIds[numOfMassages - 1];
                    var    messageMarkAsReadList   = db.ChatHistories.Where(x => x.chatRoomId == chatRoomId).Select(y => y.markAsRead).ToList();
                    bool   lastMessageMarkedAsRead = (bool)messageMarkAsReadList[numOfMassages - 1];

                    int lastUnixDate = (int)chatDate[numOfMassages - 1];

                    DateTime dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
                    dtDateTime = dtDateTime.AddSeconds(lastUnixDate).ToLocalTime();

                    //Checking if last massage was sent over the last 24 hrs
                    string   lastDate;
                    DateTime now = DateTime.Now;
                    if (dtDateTime > now.AddHours(-24) && dtDateTime <= now)
                    {
                        decimal hours        = Math.Floor((decimal)(now - dtDateTime).TotalHours);
                        int     hoursDiffInt = (int)hours;
                        if (hoursDiffInt == 0)
                        {
                            lastDate = (now - dtDateTime).Minutes.ToString();
                            if (lastDate == "0")
                            {
                                lastDate = "Now";
                            }
                            else
                            {
                                lastDate += " min ago";
                            }
                        }
                        else
                        {
                            lastDate = $"{hoursDiffInt}h ago";
                        }
                    }
                    else
                    {
                        string year  = dtDateTime.Year.ToString();
                        string month = dtDateTime.Month.ToString();
                        string day   = dtDateTime.Day.ToString();
                        lastDate = $"{day}/{month}/{year}";
                    };

                    ChatRoomDTO chatRoomDTO = new ChatRoomDTO()
                    {
                        chatRoomId              = chatRoomId,
                        otherMemberId           = otherMemberId,
                        otherMemberName         = otherMemberName,
                        otherMemberImage        = otherMemberImage,
                        latstSentence           = lastSentence,
                        lastDate                = lastDate,
                        lastMessageSenderId     = lastMessageSenderId,
                        lastMessageMarkedAsRead = lastMessageMarkedAsRead,
                        lastUnixDate            = lastUnixDate
                    };
                    chatRooms.Add(chatRoomDTO);
                }


                List <ChatRoomDTO> SortedList = chatRooms.OrderByDescending(o => o.lastUnixDate).ToList();


                return(Request.CreateResponse(HttpStatusCode.OK, SortedList));
            }
            catch (DbEntityValidationException ex)
            {
                string errors = "";
                foreach (DbEntityValidationResult vr in ex.EntityValidationErrors)
                {
                    foreach (DbValidationError er in vr.ValidationErrors)
                    {
                        errors += $"PropertyName - {er.PropertyName }, Error {er.ErrorMessage} <br/>";
                    }
                }
                return(Request.CreateResponse(HttpStatusCode.BadRequest, errors));
            }
            catch (DbUpdateException ex)
            {
                DbUpdateException e      = (DbUpdateException)ex;
                string            errors = "";
                foreach (DbEntityEntry entry in e.Entries)
                {
                    errors += $"Error in entity - {entry.Entity.GetType().Name}, entity state - {entry.State} <br/>";

                    foreach (string prop in entry.CurrentValues.PropertyNames)
                    {
                        errors += $"for column - {prop}, value - {entry.CurrentValues[prop]} <br/>";
                    }
                    errors += "---------------";
                }

                return(Request.CreateResponse(HttpStatusCode.BadRequest, errors));
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message));
            }
        }
Exemple #28
0
        public HttpResponseMessage SaveChatMessage(ChatHistoryDTO message)
        {
            VolunteerMatchDbContext db = new VolunteerMatchDbContext();

            try
            {
                //////////////////////////////////////////////////////////
                ///                        TODO:                       ///
                ///  1. CALCULATE DATETIME HERE                        ///
                //////////////////////////////////////////////////////////


                int         datetime   = (int)DateTimeOffset.Now.ToUnixTimeSeconds();
                ChatHistory newMessage = new ChatHistory()
                {
                    datetime     = datetime,
                    fromMemberId = message.fromMemberId,
                    toMemberId   = message.toMemberId,
                    text         = message.text,
                    chatRoomId   = message.chatRoomId
                };
                newMessage.markAsRead      = false;
                newMessage.meetingMsg      = false;
                newMessage.meetingUnixDate = 0;
                if (message.meetingMsg)
                {
                    newMessage.meetingMsg           = true;
                    newMessage.meetingDateLabel     = message.meetingDateLabel;
                    newMessage.meetingEventTitle    = message.meetingEventTitle;
                    newMessage.meetingTimeLabel     = message.meetingTimeLabel;
                    newMessage.meetingUnixDate      = message.meetingUnixDate;
                    newMessage.meetingLocationLabel = message.meetingLocationLabel;
                    newMessage.text = "Meeting invitation";
                }
                db.ChatHistories.Add(newMessage);
                db.SaveChanges();

                return(Request.CreateResponse(HttpStatusCode.OK, "Message saved in DB"));
            }
            catch (DbEntityValidationException ex)
            {
                string errors = "";
                foreach (DbEntityValidationResult vr in ex.EntityValidationErrors)
                {
                    foreach (DbValidationError er in vr.ValidationErrors)
                    {
                        errors += $"PropertyName - {er.PropertyName }, Error {er.ErrorMessage} <br/>";
                    }
                }
                return(Request.CreateResponse(HttpStatusCode.BadRequest, errors));
            }
            catch (DbUpdateException ex)
            {
                DbUpdateException e      = (DbUpdateException)ex;
                string            errors = "";
                foreach (DbEntityEntry entry in e.Entries)
                {
                    errors += $"Error in entity - {entry.Entity.GetType().Name}, entity state - {entry.State} <br/>";

                    foreach (string prop in entry.CurrentValues.PropertyNames)
                    {
                        errors += $"for column - {prop}, value - {entry.CurrentValues[prop]} <br/>";
                    }
                    errors += "---------------";
                }

                return(Request.CreateResponse(HttpStatusCode.BadRequest, errors));
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message));
            }
        }
Exemple #29
0
        public HttpResponseMessage GetTrophyMembers(string filter)
        {
            //CHECK IF FILTER = "allTime" OR "thisMonth"
            //THEN RETURN A LIST OF TOP RATED USERS WITH TrophyMmberDTO ACCORDING TO THE FILTER


            VolunteerMatchDbContext db = new VolunteerMatchDbContext();
            bool     exists            = false;
            DateTime monthAgo          = DateTime.Today.AddDays(-30);

            long unixTime     = ((DateTimeOffset)monthAgo).ToUnixTimeSeconds();
            int  unixMonthAgo = (int)unixTime;



            List <Review> lastMonthReviews = new List <Review>();

            try
            {
                if (filter == "allTime")
                {
                    lastMonthReviews = db.Reviews.ToList();
                }
                else
                {
                    lastMonthReviews = db.Reviews.Where(x => x.date > unixMonthAgo).ToList();
                }



                /* List<Review> lastMonthReviews = db.Reviews.Where(x => x.date > unixMonthAgo).ToList();*/
                List <Member> members = new List <Member>();

                //ADD TO MEMBERS EVERY MEMBER THAT GOT AN REVIEW IN THE LAST MONTH

                foreach (Review review in lastMonthReviews)
                {
                    if (!CheckIfUserExistsInList(members, (int)review.memberId))
                    {
                        Member member = new Member()
                        {
                            id         = (int)review.memberId,
                            fullName   = db.Members.Where(x => x.id == (int)review.memberId).Select(y => y.fullName).FirstOrDefault(),
                            pictureUrl = db.Members.Where(x => x.id == (int)review.memberId).Select(y => y.pictureUrl).FirstOrDefault()
                        };
                        members.Add(member);
                    }
                }


                List <TrophyMemberDTO> trophyMemberDTOs = new List <TrophyMemberDTO>();
                double userRating  = 0;
                int    reviewCount = 0;
                string memberName;
                string memberImage;



                foreach (Member member1 in members) // RUN ON EACH UNIQUE MEMBER THAT GOT REVIEW LAST MONTH
                {
                    foreach (Review review1 in lastMonthReviews)
                    {
                        if (review1.memberId == member1.id)
                        {
                            reviewCount++;
                            userRating += (int)review1.stars;
                        }
                        ;
                    }


                    memberName  = member1.fullName;
                    memberImage = member1.pictureUrl;



                    TrophyMemberDTO trophyMemberDTO = new TrophyMemberDTO()
                    {
                        reviewsCount  = reviewCount,
                        memberName    = memberName,
                        memberImage   = memberImage,
                        userRating    = (double)System.Math.Round(userRating / reviewCount, 2),
                        otherMemberId = member1.id
                    };

                    trophyMemberDTOs.Add(trophyMemberDTO);

                    userRating  = 0;
                    reviewCount = 0;
                }
                ;

                trophyMemberDTOs = trophyMemberDTOs.OrderByDescending(x => x.userRating).ThenByDescending(y => y.reviewsCount).ToList();



                if (filter == "allTime")
                {
                    trophyMemberDTOs = trophyMemberDTOs.Where(x => x.reviewsCount >= 5).ToList();
                }


                return(Request.CreateResponse(HttpStatusCode.OK, trophyMemberDTOs));
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message));
            }
        }
Exemple #30
0
        public HttpResponseMessage AddInteractionMember(InteractionMemberDTO interactionMemberDTO)
        {
            VolunteerMatchDbContext db = new VolunteerMatchDbContext();


            int strength = 0;

            switch (interactionMemberDTO.type)
            {
            case "Profile":
                strength = 10;
                break;

            case "Review 1":
                strength = -50;
                break;

            case "Review 2":
                strength = -10;
                break;

            case "Review 3":
                strength = 0;
                break;

            case "Review 4":
                strength = 10;
                break;

            case "Review 5":
                strength = 50;
                break;

            default:
                break;
            }
            try
            {
                InteractionsMember interactionsMember = db.InteractionsMembers.Where
                                                            (x => x.memberId == interactionMemberDTO.memberId && x.otherMemberId == interactionMemberDTO.otherMemberId).FirstOrDefault();


                if (interactionsMember == null)
                {
                    InteractionsMember interaction = new InteractionsMember()
                    {
                        memberId      = interactionMemberDTO.memberId,
                        otherMemberId = interactionMemberDTO.otherMemberId,
                        strength      = strength
                    };
                    db.InteractionsMembers.Add(interaction);
                }
                else
                {
                    interactionsMember.strength += strength;
                };

                db.SaveChanges();

                return(Request.CreateResponse(HttpStatusCode.OK, "Member strength updated"));
            }
            catch (Exception)
            {
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, "Unknown error occured"));
            }
        }