コード例 #1
0
ファイル: MemberController.cs プロジェクト: nhanthieugia/BSG
        public ActionResult Edit(MemberResponseModel model)
        {
            var updatemodel = new UpdateMemberRequestModel()
                {
                    ApiKey = null,
                    MemberAbout = model.Member.MemberAbout,
                    MemberAddress = model.Member.MemberAddress,
                    MemberAllowViewAbout = model.Member.MemberAllowViewAbout,
                    MemberAllowViewAddress = model.Member.MemberAllowViewAddress,
                    MemberAllowViewBithday = model.Member.MemberAllowViewBithday,
                    MemberAllowViewEmail = model.Member.MemberAllowViewEmail,
                    MemberAllowViewFavorite = model.Member.MemberAllowViewFavorite,
                    MemberBirthday = model.Member.MemberBirthday,
                    MemberCountry = model.Member.MemberCountry,
                    MemberEmail = model.Member.MemberEmail,
                    MemberFacebookId = model.Member.MemberFacebookId,
                    MemberFavorite = model.Member.MemberFavorite,
                    MemberFirstName = model.Member.MemberFirstName,
                    MemberGender = model.Member.MemberGender,
                    MemberId = model.Member.MemberId,
                    MemberLastName = model.Member.MemberLastName,
                    MemberUserName = model.Member.MemberUserName,
                    MemberAllowViewCompany = model.Member.MemberAllowViewCompany,
                    MemberAllowViewFacebookId = model.Member.MemberAllowViewFacebookId,
                    MemberAllowViewSkype = model.Member.MemberAllowViewSkype,
                    MemberCompany = model.Member.MemberCompany,
                    MemberAllowViewPhoneNumber = model.Member.MemberAllowViewPhoneNumber,
                    MemberSkype = model.Member.MemberSkype,
                    MemberPhoneNumber = model.Member.MemberPhoneNumber
                };

            var result = MemberRepository.UpdateMember(updatemodel);

            if (result.Code == "1")
            {
                ViewData["Success"] = true;
                return View(model);
            }

            ModelState.AddModelError("",result.Message);
            return View(model);
        }
コード例 #2
0
        /// <summary>
        /// Update member
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public MemberEditResponseModel UpdateMember(UpdateMemberRequestModel request)
        {
            if (AllowApi)
                if (!CheckApi(new Guid(request.ApiKey)))
                    return new MemberEditResponseModel()
                        {
                            Code = "-2",
                            Message = "Not allow this function for this API key. Please check again"
                        };
            using (var tx = new TransactionScope())
            {
                try
                {
                    var member = DataContext.MemberUsers.Where(m => m.MemberId == new Guid(request.MemberId)).ToList();

                    //Check user exist
                    if (member.Count == 0)
                    {
                        tx.Dispose();
                        return new MemberEditResponseModel()
                            {
                                Code = "-1",
                                Message = "User is not exist"
                            }; // User is not exist

                    }
                    var memberUpadte = member[0];

                    memberUpadte.MemberId = new Guid(request.MemberId);
                    memberUpadte.MemberUserName = request.MemberUserName;
                    memberUpadte.MemberFirstName = request.MemberFirstName;
                    memberUpadte.MemberLastName = request.MemberLastName;
                    memberUpadte.MemberCountry = request.MemberCountry;
                    memberUpadte.MemberGender = request.MemberGender;
                    memberUpadte.MemberEmail = request.MemberEmail;
                    memberUpadte.MemberAllowViewEmail = request.MemberAllowViewEmail;
                    memberUpadte.MemberFacebookId = request.MemberFacebookId;
                    memberUpadte.MemberAddress = request.MemberAddress;
                    memberUpadte.MemberAllowViewAddress = request.MemberAllowViewAddress;
                    memberUpadte.MemberBirthday = request.MemberBirthday;
                    memberUpadte.MemberAllowViewBithday = request.MemberAllowViewBithday;
                    memberUpadte.MemberAbout = request.MemberAbout;
                    memberUpadte.MemberAllowViewAbout = request.MemberAllowViewAbout;
                    memberUpadte.MemberFavorite = request.MemberFavorite;
                    memberUpadte.MemberAllowViewFavorite = request.MemberAllowViewFavorite;
                    memberUpadte.MemberLastUpdate = DateTime.Now;

                    var result = DataContext.SaveChanges();

                    tx.Complete();

                    return new MemberEditResponseModel()
                        {
                            Code = result.ToString(CultureInfo.InvariantCulture)
                        };

                }
                catch (Exception ex)
                {
                    tx.Dispose();
                    return new MemberEditResponseModel()
                        {
                            Message = ex.Message,
                            Code = "-1"
                        };
                }
            }
        }
コード例 #3
0
ファイル: AccountController.cs プロジェクト: nhanthieugia/BSG
        public ActionResult UpdateInfo(MemberInfoViewModel model)
        {
            if (ModelState.IsValid)
            {
                var updateModel = new UpdateMemberRequestModel()
                    {
                        MemberAbout = model.MemberAbout,
                        MemberAddress = model.MemberAddress,
                        MemberAllowViewAbout = model.MemberAllowViewAbout,
                        MemberAllowViewAddress = model.MemberAllowViewAddress,
                        MemberAllowViewBithday = model.MemberAllowViewBithday,
                        MemberAllowViewCompany = model.MemberAllowViewCompany,
                        MemberAllowViewEmail = model.MemberAllowViewEmail,
                        MemberAllowViewFacebookId = model.MemberAllowViewFacebookId,
                        MemberAllowViewFavorite = model.MemberAllowViewFavorite,
                        MemberAllowViewSkype = model.MemberAllowViewSkype,
                        MemberBirthday = model.MemberBirthday,
                        MemberCompany = model.MemberCompany,
                        MemberCountry = model.MemberCountry,
                        MemberEmail = model.MemberEmail,
                        MemberFacebookId = model.MemberFacebookId,
                        MemberFavorite = model.MemberFavorite,
                        MemberFirstName = model.MemberFirstName,
                        MemberGender = model.MemberGender,
                        MemberLastName = model.MemberLastName,
                        MemberId = SessionManager.UserLogged.UserId,
                        MemberSkype = model.MemberSkype,
                        MemberUserName = model.MemberUserName,
                        MemberAllowViewPhoneNumber = model.MemberAllowViewPhoneNumber,
                        MemberPhoneNumber = model.MemberPhoneNumber
                    };

                var result = MemberRepository.UpdateMember(updateModel);

                var data = MemberRepository.GetSingle(SessionManager.UserLogged.UserId, null);

                if (result.Code == "1")
                {
                   if (data.Code == "1")
                    {
                        AutoMapper.Mapper.CreateMap<MemberModel, MemberInfoViewModel>();
                        var modelMem = AutoMapper.Mapper.Map<MemberInfoViewModel>(data.Member);
                        modelMem.IsFriend = true;
                        modelMem.IsUserLogin = SessionManager.IsLoggedIn && (SessionManager.UserLogged.UserId == data.Member.MemberId);
                        return View(modelMem);
                    }

                    return RedirectToAction("Index", "Home");
                }
                ModelState.AddModelError("",result.Message);
                return View(model);
            }

            return View(model);
        }