public async Task <IActionResult> Edit([FromBody] DeptShowDto dto)
        {
            dto.SysDept.CreateUserId = UserIdentity.UserId;
            bool res = await _deptService.UpdateAsync(dto);

            return(Ok(res));
        }
Beispiel #2
0
        public async Task <bool> AddAsync(DeptShowDto dto)
        {
            using (var tran = _databaseFixture.Db.BeginTransaction())
            {
                try
                {
                    dto.SysDept.CreateTime = DateTime.Now.ToTimeStamp();
                    await _databaseFixture.Db.SysDept.InsertAsync(dto.SysDept, tran);

                    //path
                    string path = "";
                    if (dto.SysDept.ParentId > 0)
                    {
                        var parentres = await _databaseFixture.Db.SysDept.FindAsync(m => m.DeptId == dto.SysDept.ParentId);

                        if (parentres != null)
                        {
                            path = parentres.Path;
                        }
                    }
                    dto.SysDept.Path = path.IsNullOrEmpty() ? dto.SysDept.DeptId.ToString() : path + ":" + dto.SysDept.DeptId;
                    await _databaseFixture.Db.SysDept.UpdateAsync(dto.SysDept, tran);

                    tran.Commit();
                    return(true);
                }
                catch (Exception ex)
                {
                    tran.Rollback();
                    _logJobs.ExceptionLog(dto.SysDept.CreateUserId, ex);
                    return(false);
                }
            }
        }
        public async Task <bool> UpdateAsync(DeptShowDto dto)
        {
            var uri      = API.SysDept.UpdateAsync(_baseUrl);
            var content  = new StringContent(JsonConvert.SerializeObject(dto), System.Text.Encoding.UTF8, "application/json");
            var response = await _apiClient.PostAsync(uri, content);

            response.EnsureSuccessStatusCode();
            string res = await response.Content.ReadAsStringAsync();

            return(res.ToLower() == bool.TrueString.ToLower());
        }
Beispiel #4
0
        /// <summary>
        /// 编辑
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        public async Task <bool> UpdateAsync(DeptShowDto dto)
        {
            using (var tran = _databaseFixture.Db.BeginTransaction())
            {
                try
                {
                    var dbdept = await _databaseFixture.Db.SysDept.FindAsync(m => m.DeptId == dto.SysDept.DeptId);

                    if (dbdept == null)
                    {
                        return(false);
                    }

                    #region 基本信息

                    dbdept.DeptName = dto.SysDept.DeptName;
                    dbdept.DeptCode = dto.SysDept.DeptCode;
                    dbdept.ParentId = dto.SysDept.ParentId;
                    dbdept.IsDel    = dto.SysDept.IsDel;
                    dbdept.Memo     = dto.SysDept.Memo;

                    //path
                    string path = "";
                    if (dto.SysDept.ParentId > 0)
                    {
                        var parentres = await _databaseFixture.Db.SysDept.FindAsync(m => m.DeptId == dto.SysDept.ParentId);

                        if (parentres != null)
                        {
                            path = parentres.Path;
                        }
                    }
                    dbdept.Path = path.IsNullOrEmpty() ? dto.SysDept.DeptId.ToString() : path + ":" + dto.SysDept.DeptId;

                    await _databaseFixture.Db.SysDept.UpdateAsync(dbdept, tran);

                    #endregion

                    tran.Commit();
                    return(true);
                }
                catch (Exception ex)
                {
                    tran.Rollback();
                    _logJobs.ExceptionLog(dto.SysDept.CreateUserId, ex);
                    return(false);
                }
            }
        }
Beispiel #5
0
 public async Task <bool> UpdateAsync([FromBody] DeptShowDto dto)
 {
     return(await _deptService.UpdateAsync(dto));
 }