public ActionResult Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                // 尝试注册用户
                int createStatus = ManageService.UserService().CreatUser(model.UserName, model.Password, model.Email, null);
                if (createStatus == 0)
                {
                    UtilEmail.SendMail(
                        model.Email,
                        Resources.Subject,
                        "您收到此邮件是因为您是Betterlife.Net网站的会员。我们很高兴地通知您,您现在已经可以观看新的管理博客了。<br/><br/>",
                        true);
                    FormsAuthentication.SetAuthCookie(model.UserName, false /* createPersistentCookie */);
                    return(RedirectToAction("Index", "Home"));
                }
                else
                {
                    ModelState.AddModelError("", ErrorCodeToString(createStatus));
                }
            }

            // 如果我们进行到这一步时某个地方出错,则重新显示表单
            return(View(model));
        }
Exemple #2
0
        public string Send(UtilEmail utilEmail)
        {
            SmtpEmailConfig emailConfig = new SmtpEmailConfig();
            string          message     = string.Empty;

            using (MailMessage mailMessage = new MailMessage(utilEmail.Email, utilEmail.To))
            {
                mailMessage.Subject = utilEmail.Subject;
                mailMessage.Body    = utilEmail.Body;
                if (utilEmail.Attachment.Length > 0)
                {
                    string fileName = Path.GetFileName(utilEmail.Attachment.FileName);
                    mailMessage.Attachments.Add(new Attachment(utilEmail.Attachment.OpenReadStream(), fileName));
                }
                mailMessage.IsBodyHtml = utilEmail.IsBodyHtml;
                using (SmtpClient smtp = new SmtpClient())
                {
                    smtp.Host      = emailConfig.Host;
                    smtp.EnableSsl = emailConfig.EnableSsl;
                    NetworkCredential NetworkCred = new NetworkCredential(utilEmail.Email, utilEmail.Password);
                    smtp.UseDefaultCredentials = emailConfig.UseDefaultCredentials;
                    smtp.Credentials           = NetworkCred;
                    smtp.Port = emailConfig.Port;
                    smtp.Send(mailMessage);
                    message = "Email sent.";
                }
            }
            return(message);
        }
 public void TestSendEmail()
 {
     UtilEmail.SendMail(
         ToEmail,
         Subject,
         "您收到此邮件是因为您是Betterlife.Net网站的会员。我们很高兴地通知您,您现在已经可以观看新的管理博客了。<br/><br/>",
         true);
 }
 public void TestRegisterSendEmail()
 {
     UtilEmail.SendMail(
         ToEmail,
         Subject,
         @"亲爱的" + UserName + ":<br/><br/>" +
         "&nbsp;&nbsp;&nbsp;&nbsp;您好!欢迎您加入" + SEOName + "的大家庭。我们将全程为您提供贴心的服务,赶快来看看吧!<br/><br/>",
         true);
 }
 public void TestSendMailWithAttachment()
 {
     UtilEmail.SendMailWithAttachment(
         Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + "Test.dll.config",
         ToEmail,
         Subject,
         @"亲爱的" + UserName + ":<br/><br/>" +
         "附件仅是我测试使用的配置文件,如有雷同,纯属虚构!<br/><br/>",
         true);
 }
 public void TestVerifyMailAddressSendEmail()
 {
     UtilEmail.SendMail(
         ToEmail,
         Subject,
         @"亲爱的" + UserName + ":<br/><br/>" +
         "&nbsp;&nbsp;&nbsp;&nbsp;请点此链接完成邮件验证:<br/><br/> " +
         "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + LinkVerifyEmail + "<br/><br/>",
         true);
 }
        public Response Put(string jobId, string statusId, string pickupErrId = null, string deliverErrId = null)
        {
            var result = jobDeliveryDao.UpdateJobStatus(jobId, statusId, pickupErrId, deliverErrId);

            if (false == result)
            {
                response = Utility.Utils.SetResponse(response, false, Constant.ErrorCode.EGeneralError);
                return(response);
            }

            // notify owner status update
            var jobDetails        = jobDetailsDao.GetByJobId(jobId);
            var clientIdentifiers = userDao.GetDeviceIdentifier(jobDetails.ownerUserId);
            var uniqueId          = Utils.EncodeUniqueId(jobId);
            var msg = NotificationMsg.JobStatusUpdate_Desc + uniqueId;

            if (clientIdentifiers != null)
            {
                // user have app installed and identifier found, send push notification
                var extraData = Helper.PushNotification.ConstructExtraData(Helper.PushNotification.ECategories.OrderStatusUpdate, uniqueId);
                Utility.UtilNotification.BroadCastMessage(clientIdentifiers.ToArray(), extraData, NotificationMsg.NewJob_Title, msg);
            }

            /* do not use SMS for job status update
             * else
             * {
             *  // no device record, send sms instead
             *  var userObj = userDao.GetUserById(jobDetails.ownerUserId);
             *  UtilSms.SendSms(userObj.contactNumber, msg);
             * }
             */

            if (statusId == ((int)Constants.Configuration.JobStatus.Delivered).ToString())
            {
                // send email to notify user
                User userDetails = userDao.GetUserById(jobDetails.ownerUserId);
                UtilEmail.SendDelivered(userDetails.email, uniqueId, userDetails.displayName,
                                        ConfigurationManager.AppSettings.Get("RatingLink") + "?uniqueId=" + uniqueId);
            }

            response = Utility.Utils.SetResponse(response, true, Constant.ErrorCode.ESuccess);
            return(response);
        }
Exemple #8
0
        public Response Post(string jobId, string companyId, string driverId, string fleetId)
        {
            var result = jobDeliveryDao.Add(jobId, companyId, driverId, fleetId);

            if (result == null)
            {
                response = Utility.Utils.SetResponse(response, false, Constant.ErrorCode.EGeneralError);
                return(response);
            }

            // pre-caution step to avoid the job delivery cancelled
            jobDeclineDao.Remove(jobId, companyId);

            // update the job order status
            if (false == jobDeliveryDao.UpdateJobStatus(jobId, ((int)Constants.Configuration.JobStatus.OrderReceived).ToString()))
            {
                DBLogger.GetInstance().Log(DBLogger.ESeverity.Critical, string.Format("unable to update job status after partner accept the job."));
                response = Utility.Utils.SetResponse(response, false, Constant.ErrorCode.EJobNotFound);
                return(response);
            }

            // send email to notify user
            JobDetails jobDetails    = jobDetailsDao.GetByJobId(jobId);
            User       userDetails   = userDao.GetUserById(jobDetails.ownerUserId);
            User       driverDetails = userDao.GetUserById(driverId);
            Fleet      fleetDetails  = fleetDao.Get(fleetId);
            JobType    jobType       = jobTypeDao.GetById(jobDetails.jobTypeId);
            FleetType  fleetType     = fleetTypeDao.Get(jobDetails.fleetTypeId);

            var uniqueId = Utils.EncodeUniqueId(jobId);

            UtilEmail.SendOrderConfirmed(uniqueId, userDetails, jobDetails, driverDetails, fleetDetails, jobType, fleetType);

            response = Utility.Utils.SetResponse(response, true, Constant.ErrorCode.ESuccess);
            return(response);
        }
        public void Post([FromBody] Model.BillPlz.Bill bill)
        {
            foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(bill))
            {
                string name  = descriptor.Name;
                object value = descriptor.GetValue(bill);
                DBLogger.GetInstance().Log(DBLogger.ESeverity.Info, name + ": " + value);
            }

            try
            {
                if (ConfigurationManager.AppSettings.Get("Debug") != "0")
                {
                    // Debug mode, push the notification straight away

                    var debugJobId      = Utils.DecodeUniqueId(bill.reference_1);
                    var debugJobDetails = jobDetailsDao.GetByJobId(debugJobId);
                    if (debugJobDetails == null)
                    {
                        DBLogger.GetInstance().Log(DBLogger.ESeverity.Info, string.Format("Debug - Payment callback does not found job details. Job id: {0}, PaymentId: {1}. {2}", debugJobId, bill.id, bill));
                        return;
                    }

                    var extraDataPartner       = Helper.PushNotification.ConstructExtraData(Helper.PushNotification.ECategories.NewOpenJob, debugJobId);
                    var partnerListIdentifiers = userDao.GetUserIdentifiersByRoleId(((int)Constants.Configuration.Role.CompanyAdmin).ToString());
                    if (int.Parse(debugJobDetails.jobTypeId) == (int)Constants.Configuration.DeliveryJobType.Standard)
                    {
                        Utility.UtilNotification.BroadCastMessage(
                            partnerListIdentifiers.ToArray(),
                            extraDataPartner,
                            NotificationMsg.NewOpenJob_Title,
                            NotificationMsg.NewOpenJob_Desc + string.Format("From: {0}\nTo: {1}\nAmount:{2}",
                                                                            debugJobDetails.addressFrom[0].address3,
                                                                            debugJobDetails.addressTo[0].address3,
                                                                            debugJobDetails.amountPartner)
                            );
                    }
                    else if (int.Parse(debugJobDetails.jobTypeId) == (int)Constants.Configuration.DeliveryJobType.Disposal)
                    {
                        Utility.UtilNotification.BroadCastMessage(
                            partnerListIdentifiers.ToArray(),
                            extraDataPartner,
                            NotificationMsg.NewOpenJob_Title,
                            NotificationMsg.NewOpenJob_Desc + string.Format("Dispose items from: {0}\nAmount:{1}",
                                                                            debugJobDetails.addressFrom[0].address3,
                                                                            debugJobDetails.amountPartner)
                            );
                    }

                    // do not proceed for debug mode
                    return;
                }
            }
            catch (Exception e)
            {
                DBLogger.GetInstance().Log(DBLogger.ESeverity.Critical, e.Message);
                return;
            }



            var jobId      = Utils.DecodeUniqueId(bill.reference_1);
            var jobDetails = jobDetailsDao.GetByJobId(jobId);

            if (jobDetails == null)
            {
                DBLogger.GetInstance().Log(DBLogger.ESeverity.Critical, string.Format("Payment callback does not found job details. Job id: {0}, PaymentId: {1}. {2}", jobId, bill.id, bill));
                return;
            }

            // cross check the job id match with exisiting payment id
            var dbBill = paymentsDao.Get(bill.id);

            if (dbBill == null ||
                dbBill.reference_1 != jobId)
            {
                DBLogger.GetInstance().Log(DBLogger.ESeverity.Critical, string.Format("Payment callback does not found matched job id. Job id: {0}, PaymentId: {1}. {2}", jobId, bill.id, bill));
                return;
            }

            // cross check with billplz server status is correct
            var request = WebRequest.Create(string.Format("https://www.billplz.com/api/v3/bills/{0}", bill.id)) as HttpWebRequest;

            using (var responseApi = request.GetResponse() as HttpWebResponse)
            {
                using (var reader = new StreamReader(responseApi.GetResponseStream()))
                {
                    String responseContent = reader.ReadToEnd();
                    Bill   jsonObj         = JsonConvert.DeserializeObject <Bill>(responseContent);

                    // add to database
                    var id = paymentsDao.AddOrUpdate(bill.reference_1, jsonObj);
                    if (id == null || id == "0")
                    {
                        DBLogger.GetInstance().Log(DBLogger.ESeverity.Critical, string.Format("Payment callback unable to update database. Job id: {0}, PaymentId: {1}. {2}, {3}", jobId, bill.id, bill.due_at));
                        return;
                    }

                    // update the job details on the amount paid
                    var totalPaidAmount = jobDetailsDao.UpdatePaidAmount(jobId, jsonObj.paid_amount);
                    if (totalPaidAmount < jobDetails.amount)
                    {
                        DBLogger.GetInstance().Log(DBLogger.ESeverity.Warning, string.Format("Payment callback paid amount not same as total amount. Job id: {0}, PaymentId: {1}. {2}", jobId, bill.id, bill));
                        return;
                    }

                    // update the job order status
                    if (false == jobDeliveryDao.UpdateJobStatus(jobId, ((int)Constants.Configuration.JobStatus.PaymentVerifying).ToString()))
                    {
                        DBLogger.GetInstance().Log(DBLogger.ESeverity.Critical, string.Format("Payment callback unable to update job order status. Job id: {0}, PaymentId: {1}. {2}", jobId, bill.id, bill));
                        return;
                    }

                    // send notification to partners
                    var extraDataPartner       = Helper.PushNotification.ConstructExtraData(Helper.PushNotification.ECategories.NewOpenJob, jobId);
                    var partnerListIdentifiers = userDao.GetUserIdentifiersByRoleId(((int)Constants.Configuration.Role.CompanyAdmin).ToString());
                    if (int.Parse(jobDetails.jobTypeId) == (int)Constants.Configuration.DeliveryJobType.Standard)
                    {
                        Utility.UtilNotification.BroadCastMessage(
                            partnerListIdentifiers.ToArray(),
                            extraDataPartner,
                            NotificationMsg.NewOpenJob_Title,
                            NotificationMsg.NewOpenJob_Desc + string.Format("From: {0}\nTo: {1}\nAmount:{2}",
                                                                            jobDetails.addressFrom[0].address3,
                                                                            jobDetails.addressTo[0].address3,
                                                                            jobDetails.amountPartner)
                            );
                    }
                    else if (int.Parse(jobDetails.jobTypeId) == (int)Constants.Configuration.DeliveryJobType.Disposal)
                    {
                        Utility.UtilNotification.BroadCastMessage(
                            partnerListIdentifiers.ToArray(),
                            extraDataPartner,
                            NotificationMsg.NewOpenJob_Title,
                            NotificationMsg.NewOpenJob_Desc + string.Format("Dispose items from: {0}\nAmount:{1}",
                                                                            jobDetails.addressFrom[0].address3,
                                                                            jobDetails.amountPartner)
                            );
                    }

                    // temporary send email to care about the payment
                    var userObj   = userDao.GetUserById(jobDetails.ownerUserId);
                    var fleetType = fleetTypeDao.Get(jobDetails.fleetTypeId);
                    var jobType   = jobTypeDao.GetById(jobDetails.jobTypeId);
                    UtilEmail.SendOrderReceived(jobDetails.jobId, userObj, jobDetails, fleetType.name, jobType.name);
                }
            }
        }
Exemple #10
0
        public Response Post([FromBody] Model.JobDetails jobDetails, string promoCode = null)
        {
            try
            {
                // first add the user if not existed
                var userId  = jobDetails.ownerUserId;
                var userObj = userDao.GetUserById(userId);
                if (userObj == null)
                {
                    response = Utility.Utils.SetResponse(response, false, Constant.ErrorCode.EParameterError);
                    return(response);
                }

                // validate the voucher
                if (promoCode != null)
                {
                    var voucherResult = new Vouchers();

                    // TODO: bug here: as the amount pass in was discounted amount, so it might below the expected use amount
                    // best way is not taking the amount required, and recalculate here to avoid injection attack
                    var responseCode = validateVoucher(promoCode, jobDetails.amount, out voucherResult);
                    if (responseCode != Constant.ErrorCode.ESuccess)
                    {
                        response = Utility.Utils.SetResponse(response, false, responseCode);
                        return(response);
                    }

                    if (voucherDao.IncreaseUsedCount(promoCode) == false)
                    {
                        DBLogger.GetInstance().Log(DBLogger.ESeverity.Warning, "voucherDao.IncreaseUsedCount(promoCode) in Common controller: " + promoCode);
                        response = Utility.Utils.SetResponse(response, false, Constant.ErrorCode.EVoucherNotValid);
                        return(response);
                    }
                }

                // get the gps coordinate if not passed in
                // get the state id and country id if not passed in
                foreach (Model.Address address in jobDetails.addressFrom)
                {
                    if (address.gpsLongitude == 0 ||
                        address.gpsLatitude == 0 ||
                        address.stateId == null ||
                        address.countryId == null)
                    {
                        // request gps cordinate
                        AddressComponents mapsObj = Utils.GetGpsCoordinate(address.address1, address.address2, address.address3, address.postcode);
                        if (mapsObj == null)
                        {
                            // find from local database
                            Postcode postcodeClass = new Postcode();
                            string   nameLocal;
                            var      result = postcodeClass.PostcodeNameList.TryGetValue(address.postcode, out nameLocal);
                            if (result == false)
                            {
                                response = Utility.Utils.SetResponse(response, false, Constant.ErrorCode.EGeneralError);
                                return(response);
                            }
                            mapsObj = Utils.GetGpsCoordinate(nameLocal);
                        }

                        if (address.gpsLongitude == 0)
                        {
                            address.gpsLongitude = mapsObj.geometry.location.lng;
                        }

                        if (address.gpsLatitude == 0)
                        {
                            address.gpsLatitude = mapsObj.geometry.location.lat;
                        }

                        if (address.countryId == null)
                        {
                            var countryObj = countryDao.GetCountries().Find(t => t.name.Contains(mapsObj.address_components.Find(c => c.types.Contains("country")).long_name));
                            address.countryId = countryObj.countryId;
                        }

                        if (address.stateId == null)
                        {
                            var stateList = stateDao.GetByCountryId(address.countryId);
                            try
                            {
                                var stateObj = stateList.Find(t => t.name.Contains(mapsObj.address_components.Find(a => a.types.Contains("administrative_area_level_1")).long_name));
                                if (stateObj == null)
                                {
                                    // cannot find from google api, use local database
                                    Postcode postcodeClass = new Postcode();
                                    string   stateLocal;
                                    var      localDic = postcodeClass.PostcodeList.TryGetValue(address.postcode, out stateLocal);
                                    address.stateId = stateList.Find(t => t.name.Contains(stateLocal)).stateId;
                                }
                                else
                                {
                                    address.stateId = stateObj.stateId;
                                }
                            }
                            catch (Exception)
                            {
                                // cannot find from google api, use local database
                                Postcode postcodeClass = new Postcode();
                                string   stateLocal;
                                var      localDic = postcodeClass.PostcodeList.TryGetValue(address.postcode, out stateLocal);
                                address.stateId = stateList.Find(t => t.name.Contains(stateLocal)).stateId;
                            }
                        }
                    }
                }

                if (jobDetails.addressTo == null)
                {
                    jobDetails.addressTo = new List <Model.Address>();
                }

                foreach (Model.Address address in jobDetails.addressTo)
                {
                    if (address.gpsLongitude == 0 ||
                        address.gpsLatitude == 0 ||
                        address.stateId == null ||
                        address.countryId == null)
                    {
                        // request gps cordinate
                        AddressComponents mapsObj = Utils.GetGpsCoordinate(address.address1, address.address2, address.address3, address.postcode);
                        if (mapsObj == null)
                        {
                            // find from local database
                            Postcode postcodeClass = new Postcode();
                            string   nameLocal;
                            var      result = postcodeClass.PostcodeNameList.TryGetValue(address.postcode, out nameLocal);
                            if (result == false)
                            {
                                response = Utility.Utils.SetResponse(response, false, Constant.ErrorCode.EGeneralError);
                                return(response);
                            }
                            mapsObj = Utils.GetGpsCoordinate(nameLocal);
                        }

                        if (address.gpsLongitude == 0)
                        {
                            address.gpsLongitude = mapsObj.geometry.location.lng;
                        }

                        if (address.gpsLatitude == 0)
                        {
                            address.gpsLatitude = mapsObj.geometry.location.lat;
                        }

                        if (address.countryId == null)
                        {
                            var countryObj = countryDao.GetCountries().Find(t => t.name.Contains(mapsObj.address_components.Find(c => c.types.Contains("country")).long_name));
                            address.countryId = countryObj.countryId;
                        }

                        if (address.stateId == null)
                        {
                            var stateList = stateDao.GetByCountryId(address.countryId);

                            try
                            {
                                var stateObj = stateList.Find(t => t.name.Contains(mapsObj.address_components.Find(a => a.types.Contains("administrative_area_level_1")).long_name));
                                if (stateObj == null)
                                {
                                    // cannot find from google api, use local database
                                    Postcode postcodeClass = new Postcode();
                                    string   stateLocal;
                                    postcodeClass.PostcodeList.TryGetValue(address.postcode, out stateLocal);
                                    address.stateId = stateList.Find(t => t.name.Contains(stateLocal)).stateId;
                                }
                                else
                                {
                                    address.stateId = stateObj.stateId;
                                }
                            }
                            catch (Exception)
                            {
                                // cannot find from google api, use local database
                                Postcode postcodeClass = new Postcode();
                                string   stateLocal;
                                postcodeClass.PostcodeList.TryGetValue(address.postcode, out stateLocal);
                                address.stateId = stateList.Find(t => t.name.Contains(stateLocal)).stateId;
                            }
                        }
                    }
                }

                // handle if partner amount is not present
                bool notifyPartners = false;
                if (jobDetails.amountPartner == 0)
                {
                    if (jobDetails.jobTypeId == ((int)JustApi.Constants.Configuration.DeliveryJobType.Standard).ToString())
                    {
                        // standard delivery

                        // find the partner price for distance in this distance
                        StandardDeliveryController tempController = new StandardDeliveryController();
                        var priceDetails = tempController.GetPrice(jobDetails.distance.ToString(), jobDetails.fleetTypeId,
                                                                   jobDetails.addressFrom[0].buildingType, jobDetails.addressTo[0].buildingType, jobDetails.workerAssistant.ToString(),
                                                                   jobDetails.assembleBed.ToString(), jobDetails.assembleDiningTable.ToString(), jobDetails.assembleWardrobe.ToString(),
                                                                   jobDetails.assembleOfficeTable.ToString(),
                                                                   jobDetails.bubbleWrapping.ToString(), jobDetails.shrinkWrapping.ToString());

                        jobDetails.amountPartner = priceDetails.partnerTotal;
                    }
                    else if (jobDetails.jobTypeId == ((int)JustApi.Constants.Configuration.DeliveryJobType.Disposal).ToString())
                    {
                        // disposal
                        DisposalDeliveryController tempController = new DisposalDeliveryController();
                        var priceDetails = tempController.GetPrice(jobDetails.fleetTypeId, jobDetails.addressFrom[0].buildingType, promoCode);

                        jobDetails.amountPartner = priceDetails.partnerTotal;
                    }
                }
                else
                {
                    // only when admin add job then push notification
                    // else notification push when user pay using payment gateway
                    notifyPartners = true;
                }

                // add the job details
                jobDetails.createdBy  = userId;
                jobDetails.modifiedBy = userId;
                var jobId = jobDetailsDao.Add(jobDetails);
                if (jobId == null)
                {
                    response = Utility.Utils.SetResponse(response, false, Constant.ErrorCode.EGeneralError);
                    return(response);
                }

                // add the job status
                if (null == jobDetailsDao.AddOrder(jobId, userId))
                {
                    response = Utility.Utils.SetResponse(response, false, Constant.ErrorCode.EGeneralError);
                    return(response);
                }

                // add the address from, to
                foreach (Model.Address add in jobDetails.addressFrom)
                {
                    add.createdBy = userId;
                    var result = addressDao.Add(add, jobId, userObj.displayName, userObj.contactNumber, Dao.AddressDao.EType.From);
                    if (result == null)
                    {
                        response = Utility.Utils.SetResponse(response, false, Constant.ErrorCode.EGeneralError);
                        return(response);
                    }
                }

                foreach (Model.Address add in jobDetails.addressTo)
                {
                    add.createdBy = userId;
                    var result = addressDao.Add(add, jobId, userObj.displayName, userObj.contactNumber, Dao.AddressDao.EType.To);
                    if (result == null)
                    {
                        response = Utility.Utils.SetResponse(response, false, Constant.ErrorCode.EGeneralError);
                        return(response);
                    }
                }

                // generate the unique job id
                var uniqueId = Utils.EncodeUniqueId(jobId);

                // request the job payment
                PaymentController controller = new PaymentController();
                var paymentReq = controller.Post(uniqueId);

                // send notification to creator
                var clientIdentifiers = userDao.GetDeviceIdentifier(userId);
                var msg = NotificationMsg.NewJob_Desc + uniqueId;
                if (clientIdentifiers != null &&
                    clientIdentifiers.Count != 0)
                {
                    // user have app installed and identifier found, send push notification
                    var extraData = Helper.PushNotification.ConstructExtraData(Helper.PushNotification.ECategories.OrderCreated, uniqueId);
                    Utility.UtilNotification.BroadCastMessage(clientIdentifiers.ToArray(), extraData, NotificationMsg.NewJob_Title, msg);
                }

                if (ConfigurationManager.AppSettings.Get("Debug") != "0")
                {
                    // send sms together because no history of push notification
                    UtilSms.SendSms(userObj.contactNumber, msg);
                }

                // send email to user
                var fleetType = fleetTypeDao.Get(jobDetails.fleetTypeId);
                var jobType   = jobTypeDao.Get().Find(t => t.jobTypeId == jobDetails.jobTypeId);
                UtilEmail.SendInvoice(uniqueId, (string)paymentReq.payload, userObj, jobDetails, fleetType.name, jobType.name);

                if (notifyPartners)
                {
                    // update the job order status
                    if (false == jobDeliveryDao.UpdateJobStatus(jobId, ((int)Constants.Configuration.JobStatus.PaymentVerifying).ToString()))
                    {
                        DBLogger.GetInstance().Log(DBLogger.ESeverity.Critical, string.Format("Unable to update job status. Job id: {0}", jobId));
                    }

                    // send notification to partners
                    var extraDataPartner       = Helper.PushNotification.ConstructExtraData(Helper.PushNotification.ECategories.NewOpenJob, jobId);
                    var partnerListIdentifiers = userDao.GetUserIdentifiersByRoleId(((int)Constants.Configuration.Role.CompanyAdmin).ToString());
                    if (int.Parse(jobDetails.jobTypeId) == (int)Constants.Configuration.DeliveryJobType.Standard)
                    {
                        Utility.UtilNotification.BroadCastMessage(
                            partnerListIdentifiers.ToArray(),
                            extraDataPartner,
                            NotificationMsg.NewOpenJob_Title,
                            NotificationMsg.NewOpenJob_Desc + string.Format("From: {0}\nTo: {1}\nAmount:{2}",
                                                                            jobDetails.addressFrom[0].address3,
                                                                            jobDetails.addressTo[0].address3,
                                                                            jobDetails.amountPartner)
                            );
                    }
                    else if (int.Parse(jobDetails.jobTypeId) == (int)Constants.Configuration.DeliveryJobType.Disposal)
                    {
                        Utility.UtilNotification.BroadCastMessage(
                            partnerListIdentifiers.ToArray(),
                            extraDataPartner,
                            NotificationMsg.NewOpenJob_Title,
                            NotificationMsg.NewOpenJob_Desc + string.Format("Dispose items from: {0}\nAmount:{1}",
                                                                            jobDetails.addressFrom[0].address3,
                                                                            jobDetails.amountPartner)
                            );
                    }
                }

                response.payload = uniqueId;
                response         = Utility.Utils.SetResponse(response, true, Constant.ErrorCode.ESuccess);

                return(response);
            }
            catch (Exception e)
            {
                DBLogger.GetInstance().Log(DBLogger.ESeverity.Error, e.Message);
                DBLogger.GetInstance().Log(DBLogger.ESeverity.Warning, e.StackTrace);

                response = Utility.Utils.SetResponse(response, false, Constant.ErrorCode.EUnknownError);
                return(response);
            }
        }