public void StartCollaborativeSearch(Event eventt) { var now = SystemDateTime.Now; var searchers = AreYouOkEvents.Where(x => x.Event == eventt && x.ReplyDatetime != null).ToList(); foreach (var areYouOkEvent in searchers) { var list = areYouOkEvent.Target.Devices.Select(x => new BodySend() { Token = x.Token, Body = $"Se declaro una emergencia en el evento {eventt.Name}", Title = "Encuentrame", Data = new { Created = now, EventId = eventt.Id, EmergencyDateTime = eventt.EmergencyDateTime.Value, Type = "Event.StartCollaborativeSearch", } }).ToList(); ExpoPushHelper.SendPushNotification(list); } }
public void Ask(AskParameters parameters) { var now = SystemDateTime.Now; var areYouOk = new AreYouOkActivity(); areYouOk.Sender = Users[parameters.SenderId]; areYouOk.Target = Users[parameters.TargetId]; areYouOk.IAmOk = false; AreYouOkActivities.Put(areYouOk); CurrentUnitOfWork.Checkpoint(); var list = areYouOk.Target.Devices.Select(x => new BodySend() { Token = x.Token, Body = "¿estas bien?", Title = "Encuentrame", Data = new { Created = now, Id = areYouOk.Id, SenderUserId = areYouOk.Target.Id, AskDatetime = areYouOk.Created, Type = "Areyouok.Ask", } }).ToList(); ExpoPushHelper.SendPushNotification(list); }
public void AcceptContact(AcceptParameters parameters) { var now = SystemDateTime.Now; var user = Users[parameters.UserId]; var accepterUser = Users[parameters.AcceptUserId]; var contacts = user.Contacts.Where(x => x.User.Id == parameters.UserId && x.Status == ContactRequestStatus.Pending); foreach (var contact in contacts) { contact.Status = ContactRequestStatus.Accepted; contact.AcceptedDatetime = SystemDateTime.Now; } this.CurrentUnitOfWork.Checkpoint(); var list = user.Devices.Select(x => new BodySend() { Token = x.Token, Body = $"{accepterUser.FullName} ha aceptado tu solicitud de contacto!", Title = "Encuentrame", Data = new { Created = now, UserId = user.Id, Username = user.Username, Type = "Contact.Confirm" } }).ToList(); ExpoPushHelper.SendPushNotification(list); }
public IHttpActionResult Connect(long userId, long newConnectionId) { using (var uow = _unitOfwork.Create()) { var user = _userRepo.Get(new Specification <User>(s => s.Id == userId)).FirstOrDefault(); if (user == null) { return(NotFound()); } var RequestedUser = _userRepo.Get(new Specification <User>(s => s.Id == newConnectionId)).FirstOrDefault(); if (RequestedUser == null) { return(NotFound()); } UserConnection userConnection = new UserConnection() { UserId = userId, ConnectionId = newConnectionId, ConnectionStatus = ConnectionStatus.WaitingForReview }; _connectionRepo.Add(userConnection); UserConnection coonection = new UserConnection() { UserId = newConnectionId, ConnectionId = userId, ConnectionStatus = ConnectionStatus.Pending }; _connectionRepo.Add(coonection); List <NotificationObject> listNotifications = new List <NotificationObject>(); if (!String.IsNullOrEmpty(RequestedUser.PushToken)) { listNotifications.Add(new NotificationObject { to = RequestedUser.PushToken, title = "El R7laa", body = "New Request", data = new NotificationData { title = "El R7laa", body = "you have a new request form" + user.UserName, code = "NEW_CONN", id = RequestedUser.Id.ToString() } }); } ExpoPushHelper.SendPushNotification(listNotifications); } return(Ok()); }
public IHttpActionResult SubmitForReview(long vendorId, ReviewModel reviewModel) { var spec = new Specification <Order>(f => f.VendorId == vendorId && f.Id == reviewModel.OrderId); var order = _orderRepository.First(spec); if (order != null) { using (var uow = _unitOfWorkFactory.Create()) { order.ReviewData = reviewModel.ReviewData; order.Status = OrderStatus.WaitForReview; } var customer = _customerRepository.First(new ById <Customer, long>(order.CustomerId)); List <NotificationObject> listNotifications = new List <NotificationObject>(); if (!String.IsNullOrEmpty(customer.Token)) { listNotifications.Add(new NotificationObject { to = customer.Token, title = "CopyLi", body = "vendor submit your order", data = new NotificationData { title = "CopyLi", body = "vendor submit your order", code = "CUS_WAIT_REVIEW", id = order.Id.ToString() } }); } ExpoPushHelper.SendPushNotification(listNotifications); using (var uow = _unitOfWorkFactory.Create()) { OrderHistory orderHistory = new OrderHistory() { OrderStatus = OrderStatus.WaitForReview, CreatedOn = DateTime.Now, OrderId = order.Id, }; _orderHistoryRepo.Add(orderHistory); } return(Ok()); } else { return(NotFound()); } }
public IHttpActionResult ApproveConnect(long userId, long ConnectionId) { using (var uow = _unitOfwork.Create()) { var oldStatus = _connectionRepo.Get(new Specification <UserConnection>(s => s.UserId == userId && s.ConnectionId == ConnectionId)).FirstOrDefault(); oldStatus.ConnectionStatus = ConnectionStatus.Connected; var connectedoldStatus = _connectionRepo.Get(new Specification <UserConnection>(s => s.UserId == ConnectionId && s.ConnectionId == userId)).FirstOrDefault(); connectedoldStatus.ConnectionStatus = ConnectionStatus.Connected; } var RequestedUser = _userRepo.Get(new Specification <User>(s => s.Id == userId)).FirstOrDefault(); if (RequestedUser == null) { return(NotFound()); } var ConnectedUser = _userRepo.Get(new Specification <User>(s => s.Id == ConnectionId)).FirstOrDefault(); if (RequestedUser == null) { return(NotFound()); } List <NotificationObject> listNotifications = new List <NotificationObject>(); if (!String.IsNullOrEmpty(RequestedUser.PushToken)) { listNotifications.Add(new NotificationObject { to = ConnectedUser.PushToken, title = "El R7laa", body = "Approve", data = new NotificationData { title = "El R7laa", body = "" + ConnectedUser.UserName + " has approved your Request", code = "APPROVE_CONN", id = RequestedUser.Id.ToString() } }); } ExpoPushHelper.SendPushNotification(listNotifications); return(Ok()); }
public IHttpActionResult AcceptReview(long orderId) { var orderObj = _orderRepository.First(new ById <Order, long>(orderId)); if (orderObj == null) { return(BadRequest()); } using (var uow = _unitOfWorkFactory.Create()) { orderObj.Status = OrderStatus.ReviewAccepted; } List <NotificationObject> listNotifications = new List <NotificationObject>(); var vendor = _vendorRepository.First(new ById <Vendor, long>(orderObj.VendorId)); if (!String.IsNullOrEmpty(vendor.Token)) { listNotifications.Add(new NotificationObject { to = vendor.Token, title = "CopyLi", body = "Your sample reviewed by customer", data = new NotificationData { title = "CopyLi", body = "Your sample reviewed by customer", code = "VEN_ORD_REV", id = orderObj.Id.ToString() } }); } ExpoPushHelper.SendPushNotification(listNotifications); using (var uow = _unitOfWorkFactory.Create()) { OrderHistory orderHistory = new OrderHistory() { OrderStatus = OrderStatus.ReviewAccepted, CreatedOn = DateTime.Now, OrderId = orderObj.Id, }; _orderHistoryRepo.Add(orderHistory); } return(Ok()); }
public void AskFromEvent(Event eventt) { var now = SystemDateTime.Now; var activities = Activities.Where(x => x.Event == eventt); foreach (var activity in activities) { var areYouOk = new AreYouOkEvent(); areYouOk.Event = eventt; areYouOk.Target = activity.User; areYouOk.IAmOk = false; AreYouOkEvents.Put(areYouOk); } CurrentUnitOfWork.Checkpoint(); var listAsks = AreYouOkEvents.Where(x => x.Event == eventt); foreach (var areYouOkEvent in listAsks) { var list = areYouOkEvent.Target.Devices.Select(x => new BodySend() { Token = x.Token, Body = "¿estas bien?", Title = "Encuentrame", Data = new { Created = now, Id = areYouOkEvent.Id, SenderUserId = areYouOkEvent.Target.Id, AskDatetime = areYouOkEvent.Created, Type = "Areyouok.Ask", } }).ToList(); ExpoPushHelper.SendPushNotification(list); } }
public IHttpActionResult AddBidRequest(long vendorId, BidModel bidModel) { var request = _requestRepository.First <RequestDto>(new ById <Request, long>(bidModel.RequestId)); if (request == null) { return(BadRequest()); } List <NotificationObject> listNotifications = new List <NotificationObject>(); using (var uow = _unitOfWorkFactory.Create()) { RequestBid requestBid = new RequestBid() { Data = bidModel.BidData, RequestId = request.Id, Price = 0.0m, }; _requestBidRepository.Add(requestBid); } if (!String.IsNullOrEmpty(request.CustomerToken)) { listNotifications.Add(new NotificationObject { to = request.CustomerToken, title = "CopyLi", body = "Vendor add new bid", data = new NotificationData { title = "CopyLi", body = "Your bid accepted", code = "CUS_NEW_BID", id = request.Id.ToString() } }); } ExpoPushHelper.SendPushNotification(listNotifications); return(Ok()); }
public void Reply(ReplyParameters parameters) { var now = SystemDateTime.Now; var replyUser = Users[parameters.UserId]; var areYouOkActivities = AreYouOkActivities.Where(x => x.ReplyDatetime == null && x.Target == replyUser); foreach (var areYouOkActivity in areYouOkActivities) { areYouOkActivity.IAmOk = parameters.IAmOk; areYouOkActivity.ReplyDatetime = SystemDateTime.Now; var list = areYouOkActivity.Sender.Devices.Select(x => new BodySend() { Token = x.Token, Body = parameters.IAmOk ? $"{replyUser.FullName} ha indicado que está bien!" : $"{replyUser.FullName} esta con algun problema", Title = "Encuentrame", Data = new { Created = now, Id = areYouOkActivity.Id, TargetUserId = areYouOkActivity.Target.Id, Ok = parameters.IAmOk, ReplyDatetime = areYouOkActivity.ReplyDatetime, Type = "Areyouok.Reply", } }).ToList(); ExpoPushHelper.SendPushNotification(list); } var areYouOkEvents = AreYouOkEvents.Where(x => x.ReplyDatetime == null && x.Target == replyUser); foreach (var areYouOkEvent in areYouOkEvents) { areYouOkEvent.IAmOk = parameters.IAmOk; areYouOkEvent.ReplyDatetime = SystemDateTime.Now; } }
public IHttpActionResult SendPush() { List <NotificationObject> listNotifications = new List <NotificationObject>(); listNotifications.Add(new NotificationObject { to = "ExponentPushToken[GFCZKdOZLx9rgXSy2VMGEL]", title = "CopyLi", body = "Your bid accepted", data = new NotificationData { title = "CopyLi", body = "Your bid accepted", code = "VEN_BID_ACC", id = "50" } }); //tokens.Add("ExponentPushToken[GFCZKdOZLx9rgXSy2VMGEL]"); //tokens.Add("ExponentPushToken[-EWo24AUzzEGGLNe-rn-b6]"); var res = ExpoPushHelper.SendPushNotification(listNotifications); return(Ok(res)); }
public void RequestContact(RequestParameters parameters) { var now = SystemDateTime.Now; var user = Users[parameters.UserId]; var contactUser = Users[parameters.RequestUserId]; if (user.Contacts.Where(x => x.User.Id == contactUser.Id).Any()) { return; } var contact = new Contact() { User = contactUser, Status = ContactRequestStatus.Pending }; user.Contacts.Add(contact); this.CurrentUnitOfWork.Checkpoint(); var list = contactUser.Devices.Select(x => new BodySend() { Token = x.Token, Body = $"{user.FullName} quiere agregarte como contacto", Title = "Encuentrame", Data = new { Created = now, UserId = user.Id, Username = user.Username, Type = "Contact.Request" } }).ToList(); ExpoPushHelper.SendPushNotification(list); }
public IHttpActionResult AcceptRequestBid(long requestBid) { var requestBidObj = _requestBidRepository.First(new ById <RequestBid, long>(requestBid)); if (requestBidObj == null) { return(BadRequest()); } List <ItemOrder> items = new List <ItemOrder>(); var myRequest = _requestRepository.First(new ById <Request, long>(requestBidObj.RequestId)); foreach (var item in myRequest.Items) { items.Add(new ItemOrder() { Data = item.Data, Name = item.Name, Descrption = item.Descrption, ServiceTypeId = item.ServiceTypeId }); } Order order; OrderStatus orderStatus = OrderStatus.Pending; if (items.Where(i => i.ServiceTypeId == 7).Any()) { orderStatus = OrderStatus.Closed; } else { orderStatus = OrderStatus.Pending; } using (var uow = _unitOfWorkFactory.Create()) { order = new Order() { RequestId = myRequest.Id, CustomerId = myRequest.CustomerId, VendorId = requestBidObj.Request.VendorId, Items = items, CreatedOn = DateTime.Now, CreatedById = myRequest.CustomerId, BidData = requestBidObj.Data, Status = orderStatus, Latitude = myRequest.Latitude, Longitude = myRequest.Longitude }; _orderRepository.Add(order); myRequest.RequestStatus = RequestStatus.order; RequestHistory requestHistory = new RequestHistory() { CreatedOn = DateTime.Now, RequestId = myRequest.Id, CreatedById = myRequest.CustomerId, CustomerId = myRequest.CustomerId, UpdatedById = myRequest.CustomerId, RequestStatus = RequestStatus.order }; _requestHistoryRepo.Add(requestHistory); } using (var uow = _unitOfWorkFactory.Create()) { OrderHistory orderHistory = new OrderHistory() { CreatedById = myRequest.CustomerId, CreatedOn = DateTime.UtcNow, vendorId = requestBidObj.Request.VendorId, OrderStatus = orderStatus, OrderId = order.Id }; _orderHistoryRepo.Add(orderHistory); } List <NotificationObject> listNotifications = new List <NotificationObject>(); if (!String.IsNullOrEmpty(requestBidObj.Request.Vendor.Token)) { listNotifications.Add(new NotificationObject { to = requestBidObj.Request.Vendor.Token, title = "CopyLi", body = "Your bid accepted", data = new NotificationData { title = "CopyLi", body = "Your bid accepted", code = "VEN_BID_ACC", id = order.Id.ToString() } }); } ExpoPushHelper.SendPushNotification(listNotifications); return(Ok()); }