示例#1
0
        public virtual ActionResult Modify(StaffModel model)
        {
            var           result  = new Dictionary <string, object>();
            var           rev     = true;
            AccountEntity account = null;

            if (!string.IsNullOrWhiteSpace(model.LoginName) && !string.IsNullOrEmpty(model.LoginPassword))
            {
                rev = Ioc.Resolve <IPasswordApplicationService>().CheckPassword(model.LoginName, model.LoginPassword, out account);
            }
            if (!rev)
            {
                result.Add("Message", "绑定的用户名或密码错误");
            }
            else
            {
                var entity = model.CreateEntity(SaveType.Modify, account);
                rev = this.SaveEntity(entity);
                if (rev)
                {
                    result.Add("Id", entity.Id.ToString());
                    result.Add("AccountId", entity.Account == null ? 0 : entity.Account.Id);
                }
                else
                {
                    result.Add("Message", entity.Errors?.FirstOrDefault()?.Message);
                }
            }
            result.Add("Status", rev);
            return(this.Jsonp(result));
        }