예제 #1
0
 public IActionResult Post(CreateMode.Request request)
 {
     try
     {
         StatusService.CreateService service = new StatusService.CreateService();
         // Request验证
         if (request == null)
         {
             throw new Exception("Request无效!");
         }
         // Entity
         if (request.Entity != null)
         {
             request.Entity.CreateUserId   = GetUserIdFromClaim();
             request.Entity.CreateDateTime = DateTime.Now;
         }
         // Entities
         if (request.Entities != null)
         {
             request.Entities.ForEach(entity =>
             {
                 entity.CreateUserId   = GetUserIdFromClaim();
                 entity.CreateDateTime = DateTime.Now;
             });
         }
         // 指向具体执行的方法
         switch (request.Function.Name.ToLower())
         {
         default:
             if (string.IsNullOrEmpty(request.Function.Name))
             {
                 if (request.Entity != null)
                 {
                     return(base.ResponseOk(
                                request.ToResponse(
                                    service.Commit(request.Entity)
                                    )
                                ));
                 }
                 else
                 {
                     return(base.ResponseOk(
                                request.ToResponse(
                                    service.Commit(request.Entities)
                                    )
                                ));
                 }
             }
             else
             {
                 throw new Exception("未发现对应函数方法!");
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #2
0
 public IActionResult Post(CreateMode.Request request)
 {
     try
     {
         UserPowerService.CreateService service = new UserPowerService.CreateService();
         // Request验证
         if (request == null)
         {
             throw new Exception("Request无效!");
         }
         // 指向具体执行的方法
         switch (request.Function.Name.ToLower())
         {
         default:
             if (string.IsNullOrEmpty(request.Function.Name))
             {
                 if (request.Entity != null)
                 {
                     return(base.ResponseOk(
                                request.ToResponse(
                                    service.Commit(request.Entity)
                                    )
                                ));
                 }
                 else
                 {
                     return(base.ResponseOk(
                                request.ToResponse(
                                    service.Commit(request.Entities)
                                    )
                                ));
                 }
             }
             else
             {
                 throw new Exception("未发现对应函数方法!");
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }