Exemple #1
0
        public async Task RequestFinished()
        {
            var request = new OfferUpdateRequest
            {
                OfferStatusId = (int)Models.OfferStatus.Finished
            };

            await _offerService.Update <Offer>(AcceptedOfferId, request);


            var notificationRequest = new NotificationInsertRequest
            {
                CreatedAt          = DateTime.Now,
                ItemId             = Id,
                NotificationTypeId = (int)NotificationType.OfferFinished,
                UserFromId         = ClientId,
                UserToId           = SupplierId
            };

            await _notificationService.Insert <Model.Notification>(notificationRequest);

            await UpdateStatus((int)Models.Status.Finished);

            await Init();
        }
        public int NotificationInsert(NotificationInsertRequest model)
        {
            int id = 0;

            try
            {
                DataProvider.ExecuteNonQuery(GetConnection, "dbo.Notification_Insert"
                                             , inputParamMapper : delegate(SqlParameterCollection paramCollection)
                {
                    paramCollection.AddWithValue("@userId", model.UserId);
                    paramCollection.AddWithValue("@category", model.Category);
                    paramCollection.AddWithValue("@message1", model.Message1);
                    paramCollection.AddWithValue("@is_read", model.Is_Read);
                    paramCollection.AddWithValue("@link", model.Link);
                    paramCollection.AddWithValue("@message2", model.Message2);
                    paramCollection.AddWithValue("@message3", model.Message3);


                    SqlParameter p = new SqlParameter("@id", System.Data.SqlDbType.Int);
                    p.Direction    = System.Data.ParameterDirection.Output;

                    paramCollection.Add(p);
                }, returnParameters : delegate(SqlParameterCollection param)
                {
                    int.TryParse(param["@id"].Value.ToString(), out id);
                });
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(id);
        }
Exemple #3
0
        public async Task LeaveFeedback()
        {
            var request = new RatingUpsertRequest
            {
                Description  = Description,
                RatingTypeId = SelectedRatingType.RatingTypeId,
                RequestId    = Id,
                SupplierId   = SupplierId
            };

            var rating = await _ratingService.Insert <Rating>(request);

            var notificationRequest = new NotificationInsertRequest
            {
                CreatedAt          = DateTime.Now,
                ItemId             = rating.RatingId,
                NotificationTypeId = (int)NotificationType.Feedback,
                UserFromId         = ClientId,
                UserToId           = SupplierId
            };

            await _notificationService.Insert <Model.Notification>(notificationRequest);

            await Init();
        }
        // ++++++++++++++++++++++++++++++++++++++++++++++++
        // Send company a notification that another company has bid on their quote request

        public void NotifyCompanyOfNewBidOnQuoteRequestItem(int bidId)
        {
            BidDomain bid = _BidService.BidGetById(bidId);

            CompanyDomain company   = _CompanyService.GetByIdCompany(bid.ReceivingCompanyId);
            CompanyDomain company2  = _CompanyService.GetByIdCompany(bid.SubmittingCompanyId);
            string        BidAmount = String.Format("{0:0.00}", bid.Amount);


            if (company != null)
            {
                try
                {
                    EmailRequest notification = new EmailRequest();

                    notification.UserEmail = company.Email;
                    notification.Subject   = "New Bid On Your Quote Request";
                    notification.Content   = "There was a new bid on your quote request: " + bid.QrName + ". " + company2.Name + " submitted a bid of $" + BidAmount + " on the quote request item " + bid.QriName +
                                             ". The provided shipping address was " + bid.Address1 + ", " + bid.City + ", " + bid.State + " " + bid.ZipCode + ". Log into your QuoteMule account(http://quotemule.dev/) to view and take action.";


                    _UserEmailService.SendEmail(notification);


                    NotificationInsertRequest notificationModel = new NotificationInsertRequest();

                    notificationModel.UserId   = company.OwnerId;
                    notificationModel.Category = "New Bid On Your Quote Request";
                    notificationModel.Message1 = company2.Name + " submitted a bid on your quote request: " + bid.QrName + ". Click ";
                    notificationModel.Link     = "/quoterequest/manage/" + bid.QuoteRequestId;
                    notificationModel.Message2 = "here";
                    notificationModel.Message3 = " to view it.";
                    notificationModel.Is_Read  = false;

                    NotificationInsert(notificationModel);


                    NotificationInsertRequest toastrModel = new NotificationInsertRequest();

                    toastrModel.UserId   = company.OwnerId;
                    toastrModel.Category = "New Bid On Your Quote Request";
                    toastrModel.Message1 = "<a href='/quoterequest/manage/" + bid.QuoteRequestId + "#/active'>" + company2.Name + " submitted a bid on your quote request: " + bid.QrName + ".</a>";
                    toastrModel.Is_Read  = false;


                    UserProfileService UserProfile = new UserProfileService();

                    List <CompanyEmployeeDomain> notificationList = UserProfile.GetAllEmployees(bid.ReceivingCompanyId);


                    NotifyAllCompanyUsers(toastrModel, notificationList);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
Exemple #5
0
        public async Task SendNotifcationReject(int SupplierId)
        {
            var request = new NotificationInsertRequest
            {
                CreatedAt          = DateTime.Now,
                ItemId             = Id,
                NotificationTypeId = (int)NotificationType.OfferRejected,
                UserFromId         = UserId,
                UserToId           = SupplierId
            };

            await _notificationService.Insert <Model.Notification>(request);
        }
Exemple #6
0
        public async Task SendNotification()
        {
            var request = new NotificationInsertRequest
            {
                CreatedAt          = DateTime.Now,
                NotificationTypeId = (int)NotificationType.NewRequest,
                UserFromId         = UserId,
                UserToId           = ClientId,
                ItemId             = Id
            };

            await _notificationService.Insert <Model.Notification>(request);
        }
        public bool NotifySellerCompanyOfAcceptedBid(int bidId)
        {
            bool Success = false;

            BidDomain bid            = _BidService.BidGetById(bidId);
            int       QuoteRequestId = bid.QuoteRequestId;

            CompanyDomain buyerCompany    = _CompanyService.GetByIdCompany(bid.ReceivingCompanyId);
            CompanyDomain supplierCompany = _CompanyService.GetByIdCompany(bid.SubmittingCompanyId);
            string        link            = "/quoterequest/manage/" + QuoteRequestId;

            try
            {
                NotificationInsertRequest model = new NotificationInsertRequest();

                model.UserId   = supplierCompany.OwnerId;
                model.Category = "Bid Accepted";
                model.Message1 = buyerCompany.Name + " has accepted your bid! ";
                model.Link     = link;
                model.Message2 = "here";
                model.Message3 = " to convert to quote.";
                model.Is_Read  = false;

                NotificationInsert(model);


                NotificationInsertRequest toastrModel = new NotificationInsertRequest();

                toastrModel.UserId   = supplierCompany.OwnerId;
                toastrModel.Category = "Bid Accepted";
                toastrModel.Message1 = "<a href='/quoterequest/manage/" + bid.QuoteRequestId + "#/pending'><div>" + buyerCompany.Name + " has accepted your bid! Click here!</div></a>";

                UserProfileService UserProfile = new UserProfileService();

                List <CompanyEmployeeDomain> notificationList = UserProfile.GetAllEmployees(bid.SubmittingCompanyId);

                NotifyAllCompanyUsers(toastrModel, notificationList);

                Success = true;
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(Success);
        }
        public bool NotifyBuyerCompanyOfSubmittedQuote(int quoteId)
        {
            bool Success = false;

            QuoteDomain   quote         = _QuoteService.QuoteGetByQuoteId(quoteId);
            CompanyDomain buyerCompany  = _CompanyService.GetByIdCompany(quote.BuyerCompanyId);
            CompanyDomain sellerCompany = _CompanyService.GetByIdCompany(quote.SellerCompanyId);
            string        link          = "/quote/manage/" + quote.QuoteId;

            try
            {
                NotificationInsertRequest model = new NotificationInsertRequest();

                model.UserId   = buyerCompany.OwnerId;
                model.Category = "Quote Submitted";
                model.Message1 = sellerCompany.Name + " submitted a quote. Click ";
                model.Link     = link;
                model.Message2 = "here";
                model.Message3 = " to review.";
                model.Is_Read  = false;

                NotificationInsert(model);


                NotificationInsertRequest toastrModel = new NotificationInsertRequest();

                toastrModel.UserId   = buyerCompany.OwnerId;
                toastrModel.Category = "Quote Submitted";
                toastrModel.Message1 = "<a href='/quote/manage/" + quote.QuoteId + "'><div>" + sellerCompany.Name + " has submitted a quote! Click here!</div></a>";

                UserProfileService UserProfile = new UserProfileService();

                List <CompanyEmployeeDomain> notificationList = UserProfile.GetAllEmployees(quote.BuyerCompanyId);

                NotifyAllCompanyUsers(toastrModel, notificationList);


                Success = true;
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(Success);
        }
        public HttpResponseMessage NotifyReceivingCompanyOfNewBid([FromUri] NotificationInsertRequest model)
        {
            if (!ModelState.IsValid)
            {
                Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
            }

            bool success = false;

            _NotificationOptionService.NotifyCompanyOfNewBidOnQuoteRequestItem(model.BidId);

            success = true;

            ItemResponse <bool> response = new ItemResponse <bool>();

            response.Item = success;

            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }
        public bool NotifyBuyerCompanyOfApprovedContract(int quoteId)
        {
            bool Success = false;

            QuoteDomain   quote         = _QuoteService.QuoteGetByQuoteId(quoteId);
            CompanyDomain buyerCompany  = _CompanyService.GetByIdCompany(quote.BuyerCompanyId);
            CompanyDomain sellerCompany = _CompanyService.GetByIdCompany(quote.SellerCompanyId);

            try
            {
                NotificationInsertRequest model = new NotificationInsertRequest();

                model.UserId   = buyerCompany.OwnerId;
                model.Category = "Quote Completed";
                model.Message1 = sellerCompany.Name + " accepted the contract. Quote is completed!";
                model.Is_Read  = false;

                NotificationInsert(model);


                NotificationInsertRequest toastrModel = new NotificationInsertRequest();

                toastrModel.UserId   = buyerCompany.OwnerId;
                toastrModel.Category = "Contract Approved";
                toastrModel.Message1 = sellerCompany.Name + " has accepted the contract. Quote is completed!</div></a>";

                UserProfileService UserProfile = new UserProfileService();

                List <CompanyEmployeeDomain> notificationList = UserProfile.GetAllEmployees(quote.BuyerCompanyId);

                NotifyAllCompanyUsers(toastrModel, notificationList);



                Success = true;
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(Success);
        }
Exemple #11
0
        private async void BtnSave_Click(object sender, EventArgs e)
        {
            if (this.ValidateChildren())
            {
                var users = await _userService.GetAll <List <User> >(new UserSearchRequest { Username = APIService.Username });

                var user = users[0];
                NotificationInsertRequest request = new NotificationInsertRequest
                {
                    Title            = txtTitle.Text,
                    Text             = txtText.Text,
                    NotificationDate = DateTime.Now,
                    UserID           = user.UserID
                };
                await _notificationService.Insert <Notification>(request);

                MessageBox.Show("New notification successfully added!", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Close();
            }
        }
        public void NotifyAllCompanyUsers(NotificationInsertRequest model, List <CompanyEmployeeDomain> NotificationList)
        {
            //Instantialize a new NotifySmsRequest
            NotifySMSRequest       companyUser = new NotifySMSRequest();
            EmployeeProfileRequest Employee    = new EmployeeProfileRequest();

            Employee.companyId = model.CompanyId;

            //List<CompanyEmployeeDomain> notificationList = _UserProfileService.GetEmployeesByCompanyId(Employee.companyId);


            foreach (CompanyEmployeeDomain employee in NotificationList)
            {
                model.UserId    = employee.UserId;
                model.CompanyId = employee.CompanyId;



                companyUser.Phone = employee.PhoneNumber;

                //Send out text message
                try
                {
                    NotifySMSService.SendBidNotification(companyUser);
                }

                catch (ArgumentException)
                {
                    companyUser.Phone = "";
                }

                catch (Exception)
                {
                }

                SignalRHub.SendNotification(model);
            }
        }