Esempio n. 1
0
        public virtual JsonResult AccountSync(MemberDataVM memberData)
        {
            string from = "APILOGINFO - " + HttpContext.Request.UserHostAddress;
            InsideWordWebLog.Instance.Buffer(from, "AccountSync()");

            ProviderCurrentMember currentMember = ProviderCurrentMember.Instance;
            MemberServerDataVM returnMessage = new MemberServerDataVM();

            if (!currentMember.IsLoggedOn)
            {
                returnMessage.StatusCode = (int)MemberServerDataVM.StatusEnum.failure;
                returnMessage.StatusMessage = "You must be logged in to use this command. Use the API function " + Url.Action(MVC.API.Login()) + " to login.";
            }
            else
            {
                ApiBL.UpdateAccount(currentMember, memberData);
                List<AlternateCategoryMapVM> Map = ApiBL.MapCategories(currentMember, memberData.MemberToIWMap);
                returnMessage = new MemberServerDataVM(currentMember, Map, ProviderCategory.Root);
                returnMessage.ProfileLink = Url.ActionAbsolute(MVC.Member.Profile(currentMember.Id.Value, null));
                returnMessage.AccountLink = Url.ActionAbsolute(MVC.Member.Account(currentMember.Id.Value, null));
            }

            InsideWordWebLog.Instance.Buffer(from, "Done AccountSync");

            return Json(returnMessage);
        }
Esempio n. 2
0
        public static bool UpdateAccount(ProviderCurrentMember currentMember, MemberDataVM data)
        {
            MailAddress validEmail;
            if (!string.IsNullOrWhiteSpace(data.Email) && IWStringUtility.TryParse(data.Email, out validEmail))
            {
                long? memberId = ProviderEmail.FindOwner(validEmail);

                // the e-mail has not been taken so we can take it
                if(!memberId.HasValue)
                {
                    List<ProviderEmail> emailList = currentMember.Emails;
                    if (!emailList.Exists(anEmail => anEmail.Email.Address == validEmail.Address))
                    {
                        // this e-mail doesn't exist so add it
                        ProviderEmail newEmail = new ProviderEmail();
                        newEmail.CreateDate = DateTime.UtcNow;
                        newEmail.EditDate = DateTime.UtcNow;
                        newEmail.Email = validEmail;
                        newEmail.IsValidated = false;
                        newEmail.MemberId = currentMember.Id.Value;
                        newEmail.Save();
                    }
                }
            }

            return true;
        }