Example #1
0
        async public Task <ApiResult> _Edit([FromForm] int ParentId, [FromForm] string Name, [FromForm] string FullName, [FromForm] int Id, [FromForm] DateTime CreateTime, [FromForm] DateTime UpdateTime, [FromForm] bool IsDeleted, [FromForm] int Sort)
        {
            var item = new OrgDepartment();

            item.Id = Id;
            using (var ctx = fsql.CreateDbContext())
            {
                ctx.Attach(item);
                item.ParentId   = ParentId;
                item.Name       = Name;
                item.FullName   = FullName;
                item.CreateTime = CreateTime;
                item.UpdateTime = UpdateTime;
                item.IsDeleted  = IsDeleted;
                item.Sort       = Sort;
                await ctx.UpdateAsync(item);

                var affrows = await ctx.SaveChangesAsync();

                if (affrows > 0)
                {
                    return(ApiResult.Success.SetMessage($"更新成功,影响行数:{affrows}"));
                }
            }
            return(ApiResult.Failed);
        }
Example #2
0
        async public Task <ApiResult> AddOrUpdate([FromForm] int?id, [FromForm] string name, [FromForm] int parentId, [FromForm] int sort)
        {
            var depart = new OrgDepartment
            {
                Id       = id ?? 0,
                Name     = name,
                ParentId = parentId,
                Sort     = sort
            };
            await depart.SaveAsync();

            return(ApiResult.Success);
        }
Example #3
0
        async public Task <ApiResult> _Add([FromForm] int ParentId, [FromForm] string Name, [FromForm] string FullName, [FromForm] DateTime CreateTime, [FromForm] DateTime UpdateTime, [FromForm] bool IsDeleted, [FromForm] int Sort)
        {
            var item = new OrgDepartment();

            item.ParentId   = ParentId;
            item.Name       = Name;
            item.FullName   = FullName;
            item.CreateTime = CreateTime;
            item.UpdateTime = UpdateTime;
            item.IsDeleted  = IsDeleted;
            item.Sort       = Sort;
            using (var ctx = fsql.CreateDbContext())
            {
                await ctx.AddAsync(item);

                await ctx.SaveChangesAsync();
            }
            return(ApiResult <object> .Success.SetData(item));
        }
Example #4
0
 public OrgDepartmentCollection GetSubCharge(string employeeID)
 {
     OrgDepartmentCollection depts = new OrgDepartmentCollection();
     if (!string.IsNullOrEmpty(employeeID))
     {
         SFITeachers data = new SFITeachers();
         data.TeacherID = employeeID;
         if (this.teacherEntity.LoadRecord(ref data))
         {
             OrgDepartment dept = new OrgDepartment();
             dept.DepartmentID = data.SchoolID;
             dept.DepartmentName = data.SchoolName;
             depts.Add(dept);
         }
     }
     return depts;
 }