Beispiel #1
0
        public async Task CreatePartner(PartnerRequest partnerRequest)
        {
            // Convert the partner request to a new partner
            var partner = partnerRequest.ToPartner();

            // Add the partner record
            var newPartner = await partnerRepository.AddPartner(partner).ConfigureAwait(false);

            // Make the creator of the partner request a registered user for the partner
            var partnerUser = new PartnerUser
            {
                PartnerId           = newPartner.Id,
                UserId              = partnerRequest.CreatedByUserId,
                CreatedByUserId     = partnerRequest.CreatedByUserId,
                LastUpdatedByUserId = partnerRequest.LastUpdatedByUserId,
            };

            await partnerUserRepository.AddPartnerUser(partnerUser).ConfigureAwait(false);

            // Notify user when their request has been approved and what to do next
            // Need a template for this
            //var email = new Email
            //{
            //    Message = $"From Email: {partnerRequest.PrimaryEmail}\nFrom Name:{partnerRequest.Name}\nMessage:\n{partnerRequest.Notes}",
            //    Subject = "Partner Request"
            //};
            //email.Addresses.Add(new EmailAddress { Name = Constants.TrashMobEmailName, Email = Constants.TrashMobEmailAddress });

            //await emailManager.SendSystemEmail(email, CancellationToken.None).ConfigureAwait(false);
        }
        public async Task <IActionResult> AddPartnerRequest(PartnerRequest partnerRequest)
        {
            var user = await userRepository.GetUserByInternalId(partnerRequest.CreatedByUserId).ConfigureAwait(false);

            if (user == null || !ValidateUser(user.NameIdentifier))
            {
                return(Forbid());
            }

            await partnerRequestRepository.AddPartnerRequest(partnerRequest).ConfigureAwait(false);

            var message     = $"From Email: {partnerRequest.PrimaryEmail}\nFrom Name:{partnerRequest.Name}\nMessage:\n{partnerRequest.Notes}";
            var htmlMessage = $"From Email: {partnerRequest.PrimaryEmail}\nFrom Name:{partnerRequest.Name}\nMessage:\n{partnerRequest.Notes}";
            var subject     = "Partner Request";

            var recipients = new List <EmailAddress>
            {
                new EmailAddress {
                    Name = Constants.TrashMobEmailName, Email = Constants.TrashMobEmailAddress
                }
            };

            await emailManager.SendGenericSystemEmail(subject, message, htmlMessage, recipients, CancellationToken.None).ConfigureAwait(false);

            return(Ok());
        }
        public IActionResult Delete(PartnerRequest p)
        {
            prRepository.Delete(p);

            TempData["message"] = "Your request has been deleted.";
            return(RedirectToAction("Index", "Preference"));
        }
Beispiel #4
0
 /// <summary>
 ///    From Partner Request to Partner Request pivot.
 /// </summary>
 /// <param name="partnerRequest"></param>
 /// <returns>Partner Request pivot result.</returns>
 public static PartnerRequestPivot ToPivot(this PartnerRequest partnerRequest)
 {
     return(new PartnerRequestPivot()
     {
         PartnerPivot = partnerRequest.PartnerDto?.ToPivot(),
         FindPartnerPivot = Utility.EnumToEnum <FindPartnerDto, FindPartnerPivot>(partnerRequest.FindPartnerDto)
     });
 }
Beispiel #5
0
        // Update the records of a particular Partner Request
        public async Task <PartnerRequest> UpdatePartnerRequest(PartnerRequest partnerRequest)
        {
            mobDbContext.Entry(partnerRequest).State = EntityState.Modified;
            partnerRequest.LastUpdatedDate           = DateTimeOffset.UtcNow;
            await mobDbContext.SaveChangesAsync().ConfigureAwait(false);

            return(await mobDbContext.PartnerRequests.FindAsync(partnerRequest.Id).ConfigureAwait(false));
        }
 public ActionResult PartnerRequest(PartnerRequest partnerRequest)
 {
     InvertoryViewModel = new InvertoryViewModel();
     InvertoryViewModel.PartnerRequest = new PartnerRequest()
     {
         EndUserMessage = "با موفقیت اضافه شد"
     };
     return(View(PartnerViewModel));
 }
        public void GetChangedStockListbyLastAccessTest()
        {
            var request = new PartnerRequest()
            {
                PartnerId = PartnerID, UserRequestInfo = User
            };
            var stocksLastAccess = Client.GetChangedStockListbyLastAccess(request);

            Assert.IsTrue(stocksLastAccess.WasSuccessful);
        }
        public void GetStocksRecentBidsTest()
        {
            var request = new PartnerRequest()
            {
                PartnerId = PartnerID, UserRequestInfo = User
            };
            var stockRecentBid = Client.GetStocksRecentBids(request);

            Assert.IsTrue(stockRecentBid.WasSuccessful);
        }
        public void GetBuyItNowStocksTest()
        {
            var request = new PartnerRequest()
            {
                PartnerId = PartnerID, UserRequestInfo = User
            };
            var stocks = Client.GetBuyItNowStocks(request);

            Assert.IsTrue(stocks.WasSuccessful);
        }
Beispiel #10
0
        public ResponseStatus AddPartnerRequest(PartnerRequest partnerRequest)
        {
            string query = "INSERT INTO [dbo].[PartnerRequest]([RequestKind],[RequestDescription]" +
                           ")VALUES(N'" + partnerRequest.RequestKind + "',N'" + partnerRequest.RequestDescription + "')";

            SqlCommand queryCommand = new SqlCommand(query, DBConnection);

            queryCommand.ExecuteNonQuery();
            DBConnection.Close();
            return(ResponseStatus.Success);
        }
Beispiel #11
0
        public async Task <IActionResult> UpdatePartnerRequest(Guid userId, PartnerRequest partnerRequest)
        {
            var user = await userRepository.GetUserByInternalId(userId).ConfigureAwait(false);

            if (user == null || !ValidateUser(user.NameIdentifier) || user.IsSiteAdmin)
            {
                return(Forbid());
            }

            return(Ok(await partnerRequestRepository.UpdatePartnerRequest(partnerRequest).ConfigureAwait(false)));
        }
Beispiel #12
0
        public async Task <PartnerRequest> AddPartnerRequest(PartnerRequest partnerRequest)
        {
            partnerRequest.Id                  = Guid.NewGuid();
            partnerRequest.CreatedDate         = DateTimeOffset.UtcNow;
            partnerRequest.LastUpdatedByUserId = partnerRequest.CreatedByUserId;
            partnerRequest.LastUpdatedDate     = DateTimeOffset.UtcNow;

            mobDbContext.PartnerRequests.Add(partnerRequest);

            await mobDbContext.SaveChangesAsync().ConfigureAwait(false);

            return(await mobDbContext.PartnerRequests.FindAsync(partnerRequest.Id).ConfigureAwait(false));
        }
        /// <summary>
        /// Validation delete partner.
        /// </summary>
        /// <param name="request">the request to validate.</param>
        /// <returns>errors validation</returns>
        private List <string> ValidateFindPartners(PartnerRequest request)
        {
            var errors = new List <string>();

            if (request?.PartnerDto == null)
            {
                errors.Add(PartnerMessageResource.NullRequest);
            }
            else
            {
                errors.AddRange(GenericValidationAttribute <PartnerDto> .ValidateAttributes("PartnerId", request.PartnerDto.PartnerId.ToString()));
            }
            return(errors);
        }
        /// <summary>
        /// Validation update partner.
        /// </summary>
        /// <param name="request">the request to validate.</param>
        /// <returns>errors validation</returns>
        private List <string> ValidateUpdatePartner(PartnerRequest request)
        {
            var errors = new List <string>();

            if (request?.PartnerDto == null)
            {
                errors.Add(PartnerMessageResource.NullRequest);
            }
            else
            {
                errors.AddRange(GenericValidationAttribute <PartnerDto> .ValidateAttributes("PartnerName", request.PartnerDto.PartnerName));
                errors.AddRange(GenericValidationAttribute <PartnerDto> .ValidateAttributes("PartnerLink", request.PartnerDto.PartnerLink));
            }
            return(errors);
        }
        public void Create(string username)
        {
            var user = this.userService.GetUserByUsername(username);

            if (user == null || this.db.PartnerRequests.Any(x => x.XeonUser == user))
            {
                return;
            }

            var partnerRequest = new PartnerRequest {
                XeonUser = user
            };

            this.db.PartnerRequests.Add(partnerRequest);
            this.db.SaveChanges();
        }
        /// <summary>
        /// Delete Partner
        /// </summary>
        /// <param name="request">partner request.</param>
        /// <returns>Partner message.</returns>
        public PartnerMessage DeletePartner(PartnerRequest request)
        {
            PartnerMessage message = new PartnerMessage();

            try
            {
                _servicePartner.DeletePartner(request.ToPivot());
                message.OperationSuccess = true;
            }
            catch (Exception e)
            {
                message.ErrorType    = ErrorType.TechnicalError;
                message.ErrorMessage = e.Message;
            }
            return(message);
        }
Beispiel #17
0
 public static Partner ToPartner(this PartnerRequest originalPartnerRequest)
 {
     return(new Partner
     {
         Id = Guid.NewGuid(),
         Name = originalPartnerRequest.Name,
         Notes = originalPartnerRequest.Notes,
         PartnerStatusId = (int)PartnerStatusEnum.Inactive,
         PrimaryEmail = originalPartnerRequest.PrimaryEmail,
         SecondaryEmail = originalPartnerRequest.SecondaryEmail,
         PrimaryPhone = originalPartnerRequest.PrimaryPhone,
         SecondaryPhone = originalPartnerRequest.SecondaryPhone,
         CreatedByUserId = originalPartnerRequest.CreatedByUserId,
         CreatedDate = originalPartnerRequest.CreatedDate,
         LastUpdatedByUserId = originalPartnerRequest.LastUpdatedByUserId,
         LastUpdatedDate = originalPartnerRequest.LastUpdatedDate,
     });
 }
        public IHttpActionResult UpdatePartner(PartnerRequest request)
        {
            List <string>  errors  = ValidateUpdatePartner(request);
            PartnerMessage message = new PartnerMessage();

            if (errors != null && errors.Any())
            {
                message.ErrorMessage     = PartnerMessageResource.ValidationErrors;
                message.ErrorType        = ErrorType.ValidationError;
                message.Errors           = new List <string>();
                message.OperationSuccess = false;
                message.Errors.AddRange(errors);
            }
            else
            {
                message = _servicePartnerClient.UpdatePartner(request);
            }
            return(Json(message));
        }
Beispiel #19
0
        public async Task <IActionResult> Create(Game game)
        {
            Game g = gameRepository.GetGamesByTitle(game.Title).First();
            User u = await user.FindByNameAsync(HttpContext.User.Identity.Name);

            List <PartnerRequest> p = repository.GetUnfilledNotCreatedByUser(u.UserName);
            var unMatchedByGame     = p.Where(r => r.SelectedGame == g).ToList();

            if (unMatchedByGame.Count == 0)
            {
                PartnerRequest request = new PartnerRequest()
                {
                    Requester      = u,
                    RequestDate    = DateTime.Now,
                    SelectedGame   = g,
                    HasBeenMatched = false
                };
                repository.Create(request);
                TempData["message"] = "Your request has been created. Please check back later when we have found you a match";
            }
            else
            {
                var requestFound = unMatchedByGame.First();
                requestFound.MatchedPartner   = u;
                requestFound.HasBeenMatched   = true;
                requestFound.RequestCompleted = DateTime.Now;
                repository.Update(requestFound);

                PartnerRequest request = new PartnerRequest()
                {
                    Requester        = u,
                    RequestDate      = DateTime.Now,
                    SelectedGame     = g,
                    HasBeenMatched   = true,
                    RequestCompleted = DateTime.Now,
                    MatchedPartner   = requestFound.Requester
                };
                repository.Create(request);

                TempData["message"] = "Eureka! We have found you a partner. Check your profile for details.";
            }
            return(RedirectToAction("Index", "Game"));
        }
Beispiel #20
0
 public BaseResponse AddPartnerRequest(PartnerRequest partnerRequest)
 {
     try
     {
         return(new BaseResponse()
         {
             Status = partnerRepository.AddPartnerRequest(partnerRequest),
             EndUserMessage = "با موفقیت اضافه شد"
         });
     }
     catch (Exception ex)
     {
         return(new BaseResponse()
         {
             Status = ResponseStatus.InternalError,
             EndUserMessage = "یک مشکل پیش آماده است"
         });
     }
 }
 public void Create(PartnerRequest request)
 {
     context.Requests.Add(request);
     context.SaveChanges();
 }
 public void Delete(PartnerRequest request)
 {
     context.Requests.Remove(request);
     context.SaveChanges();
 }
Beispiel #23
0
        private void bw_Delivery_DoWork(object sender, DoWorkEventArgs e)
        {       // Delivered message start parsing ...
            try
            {
                bool res;

                CurrentLogMessage c2 = null;
                DeliverMessage.Delivered_Message delmsg = (DeliverMessage.Delivered_Message)e.Argument;
                if (delmsg.Short_code == SharedParams.Short_Code.ToString())
                {
                    DeliverMessage DeliverMsg = new DeliverMessage(db, partnerManager, partnerActivityRepo, _logger);
                    DeliverMessage.RequestReturnValue RQretuenvalue = new DeliverMessage.RequestReturnValue();
                    var RQpack  = new PartnerRequest();
                    var queueNo = getCurrentChannelNo();
                    RQretuenvalue = DeliverMsg.Parse_Request(delmsg, queueNo, out RQpack);
                    if (RQretuenvalue.Ret_Status == true)
                    {
                        c2 = new CurrentLogMessage("", SharedParams.Short_Code.ToString(), RQpack.MobileNo,
                                                   RQpack.RequestName + " - " + RQpack.Shortcode + " - " + RQpack.ReplayDesc + " success (" + RQpack.Id + ") Q(" + queueNo + ")", "partnerok");
                        bw_Delivery.ReportProgress(0, c2);
                        if (RQpack.RequestId == 3)
                        {
                            var result = new PartnerRequestRepo(db).Create(RQpack);
                        }
                    }
                    else
                    {
                        if (RQretuenvalue.Ret_ID == -1)
                        {
                            CurrentLogMessage c = new CurrentLogMessage("S", SharedParams.Short_Code.ToString(), RQpack.MobileNo, RQretuenvalue.Ret_Message_to_Client, "partnererror");
                            e.Result = c;
                            var BadRequest = new PartnerRequest();
                            BadRequest.MobileNo      = RQpack.MobileNo;
                            BadRequest.Shortcode     = SharedParams.Short_Code.ToString();
                            BadRequest.Content       = RQpack.Content;
                            BadRequest.Error         = RQretuenvalue.Ret_Message;
                            BadRequest.AccessChannel = "sms";
                            BadRequest.QueueNo       = 1;
                            BadRequest.RequestId     = RQpack.RequestId;
                            BadRequest.ReplayDesc    = RQretuenvalue.Ret_Message_to_Client;
                            BadRequest.ReplayTime    = DateTime.Now;
                            BadRequest.Status        = 2;

                            res = (new PartnerRequestRepo(db).Create(BadRequest).Success);

                            if (res == false)
                            {
                                c2       = new CurrentLogMessage("", SharedParams.Short_Code.ToString(), RQpack.MobileNo, "failed to create bad request [" + RQretuenvalue.Ret_Message_to_Client + "]", "error");
                                e.Result = c2;
                            }
                            if (!string.IsNullOrEmpty(RQretuenvalue.Ret_Message_to_Client))
                            {
                                var outmessage = new SMSOut();
                                outmessage.Message  = RQretuenvalue.Ret_Message_to_Client;
                                outmessage.Receiver = RQpack.MobileNo;
                                res = (new OutSMSRepo(db).Create(outmessage).Success);
                                if (res == false)
                                {
                                    c2       = new CurrentLogMessage("", SharedParams.Short_Code.ToString(), RQpack.MobileNo, "failed to create sms to client [" + RQretuenvalue.Ret_Message_to_Client + "]", "error");
                                    e.Result = c2;
                                }
                            }
                        }
                        else if (RQretuenvalue.Ret_ID == -2)
                        {
                            CurrentLogMessage c = new CurrentLogMessage("", SharedParams.Short_Code.ToString(), RQpack.MobileNo, RQretuenvalue.Ret_Message, "partnererror");
                            e.Result = c;
                        }
                    }//res==true
                }
                delmsg = null;
            }
            catch (Exception ex)
            {
                CurrentLogMessage c1 = new CurrentLogMessage("", SharedParams.Short_Code.ToString(), "", ex.Message, "error");
                WriteLog(c1);
            }
        } // bw_Delivery_DoWork
 public void Update(PartnerRequest request)
 {
     context.Requests.Update(request);
     context.SaveChanges();
 }
Beispiel #25
0
        public OpertionResult Create(PartnerRequest req)
        {
            try
            {
                #region Parameters
                var parameters = new List <OracleParameter> {
                    new OracleParameter {
                        ParameterName = "retVal", OracleDbType = OracleDbType.Int32, Direction = ParameterDirection.ReturnValue
                    },
                    new OracleParameter {
                        ParameterName = "v_req_id", OracleDbType = OracleDbType.Int32, Value = req.RequestId
                    },
                    new OracleParameter {
                        ParameterName = "v_req_content", OracleDbType = OracleDbType.Varchar2, Value = req.Content
                    },
                    new OracleParameter {
                        ParameterName = "v_replay_time", OracleDbType = OracleDbType.Date, Value = req.ReplayTime
                    },
                    new OracleParameter {
                        ParameterName = "v_replay_desc", OracleDbType = OracleDbType.Varchar2, Value = req.ReplayDesc
                    },
                    new OracleParameter {
                        ParameterName = "v_replay_shortcode", OracleDbType = OracleDbType.Varchar2, Value = req.Shortcode
                    },
                    new OracleParameter {
                        ParameterName = "v_status", OracleDbType = OracleDbType.Int32, Value = req.Status
                    },
                    new OracleParameter {
                        ParameterName = "v_queue_no", OracleDbType = OracleDbType.Int32, Value = req.QueueNo
                    },
                    new OracleParameter {
                        ParameterName = "v_error", OracleDbType = OracleDbType.Varchar2, Value = req.Error
                    },
                    new OracleParameter {
                        ParameterName = "v_accesschannel", OracleDbType = OracleDbType.Varchar2, Value = req.AccessChannel
                    },
                };
                #endregion
                db.ExecuteStoredProc("pk_infra.fn_create_partner_request", parameters);
                var result = int.Parse(parameters.Find(x => x.ParameterName == "retVal").Value.ToString());

                if (result > 0)
                {
                    return(new OpertionResult {
                        AffectedCount = result, Success = true, Error = string.Empty
                    });
                }
                else
                {
                    return(new OpertionResult {
                        AffectedCount = result, Success = false, Error = string.Empty
                    });
                }
            }
            catch (Exception ex)
            {
                return(new OpertionResult {
                    AffectedCount = -1, Success = false, Error = ex.Message
                });
            }
        }