Example #1
0
        public ActionResult Edit(MemberModel model, int id, string cutPara)
        {
            if (ModelState.IsValid)
            {
                string fileLink = "";

                // file
                if (Request.Files != null &&
                    Request.Files.Count > 0 &&
                    Request.Files[0].ContentLength > 0)
                {
                    int x = 0, y = 0, width = 0, height = 0;
                    if (!string.IsNullOrEmpty(cutPara))
                    {
                        var paras = cutPara.Split(',').Select(s => s.ToDouble()).ToArray();

                        if (paras.Length == 4)
                        {
                            x      = (int)paras[0];
                            y      = (int)paras[1];
                            width  = (int)paras[2];
                            height = (int)paras[3];

                            fileLink      = FileHelper.SaveMemberImage(Request.Files[0], x, y, width, height);
                            model.Picture = fileLink;
                        }
                    }
                }

                // info
                var member = jlService.GetMember(id);
                if (fileLink != "")
                {
                    member.Picture = fileLink;
                }
                member.Address     = model.Address;
                member.Description = model.Description;
                member.Email       = model.Email;
                member.JoinTime    = model.JoinTime ?? DateTime.Now;
                member.NickName    = model.NickName;
                member.Phone       = model.Phone;
                member.QQ          = model.QQ;
                member.RealName    = model.Name;
                member.Status      = model.Status;
                member.Weixin      = model.Weixin;
                member.Words       = model.Words;
                jlService.UpdateMember(member);

                ViewData.Add("ResultObject", ResultObject.Succeed());
            }

            return(View(model));
        }