Exemplo n.º 1
0
        public static MsCrmResult CreateUserCodeUsage(UserCodeUsage userCodeUsage, IOrganizationService service)
        {
            MsCrmResult returnValue = new MsCrmResult();

            try
            {
                Entity ent = userCodeUsage.ToCrmEntity();

                returnValue.CrmId   = service.Create(ent);
                returnValue.Success = true;
                returnValue.Result  = userCodeUsage.Point.ToString() + " puan kazandınız.";
            }
            catch (Exception ex)
            {
                returnValue.Result = ex.Message;
            }

            return(returnValue);
        }
Exemplo n.º 2
0
        public static MsCrmResult CreateUserCodeUsage(UserCodeUsage userCodeUsage, IOrganizationService service)
        {
            MsCrmResult returnValue = new MsCrmResult();

            try
            {
                Entity ent = userCodeUsage.ToCrmEntity();

                returnValue.CrmId = service.Create(ent);
                returnValue.Success = true;
                returnValue.Result = userCodeUsage.Point.ToString() + " puan kazandınız.";
            }
            catch (Exception ex)
            {
                returnValue.Result = ex.Message;
            }

            return returnValue;
        }
Exemplo n.º 3
0
        public MsCrmResult UsePointCode(string token, string pointCode)
        {
            MsCrmResult returnValue = new MsCrmResult();
            LoginSession ls = new LoginSession();

            try
            {
                if (!string.IsNullOrEmpty(token))
                {
                    #region | CHECK SESSION |
                    MsCrmResultObject sessionResult = GetUserSession(token);

                    if (!sessionResult.Success)
                    {
                        returnValue.Result = sessionResult.Result;
                        return returnValue;
                    }
                    else
                    {
                        ls = (LoginSession)sessionResult.ReturnObject;
                    }

                    #endregion

                    IOrganizationService service = MSCRM.GetOrgService(true);

                    sda = new SqlDataAccess();
                    sda.openConnection(Globals.ConnectionString);

                    MsCrmResultObject resultGetPointCodeInfo = PointCodeHelper.GetPointCodeInfo(pointCode, sda);

                    if (resultGetPointCodeInfo.Success)
                    {
                        PointCode pCode = resultGetPointCodeInfo.GetReturnObject<PointCode>();

                        if (pCode.Status.AttributeValue == 1) //Etkin ise
                        {
                            returnValue = PointCodeHelper.PassiveCode(pCode.Id, service);

                            if (returnValue.Success)
                            {
                                UserCodeUsage userCodeUsage = new UserCodeUsage();
                                userCodeUsage.Name = pointCode;
                                userCodeUsage.Point = pCode.Point;
                                userCodeUsage.PointCodeId = new EntityReferenceWrapper() { Id = pCode.Id, Name = pCode.Name, LogicalName = "new_pointcode" };
                                userCodeUsage.PortalId = new EntityReferenceWrapper() { Id = ls.PortalId, LogicalName = "new_portal" };
                                userCodeUsage.UserId = new EntityReferenceWrapper() { Id = ls.PortalUserId, LogicalName = "new_user" };

                                returnValue = PointCodeHelper.CreateUserCodeUsage(userCodeUsage, service);

                                Score sc = new Score()
                                {
                                    Point = pCode.Point,
                                    Portal = userCodeUsage.PortalId.ToCrmEntityReference(),
                                    User = userCodeUsage.UserId.ToCrmEntityReference(),
                                    ScoreType = ScoreType.PointCode
                                };

                                MsCrmResult scoreRes = ScoreHelper.CreateScore(sc, service);
                            }
                        }
                        else
                        {
                            returnValue.Result = "Girmiş olduğunuz kod önceden kullanılmıştır.";
                        }
                    }
                    else
                    {
                        returnValue.Result = resultGetPointCodeInfo.Result;
                    }
                }
                else
                {
                    returnValue.Success = false;
                    returnValue.Result = "M003"; //"Eksik parametre!-CreateForumSubject";

                }

            }
            catch (Exception ex)
            {
                returnValue.Result = ex.Message;
            }

            return returnValue;
        }