コード例 #1
0
 public async Task <IActionResult> EditGroup([FromBody] CreateUpdateGroupRequest createUpdateGroupRequest)
 {
     try
     {
         Helper helper = new Helper(_configuration);
         CreateUpdateGroupResponse createUpdateGroupResponse = new CreateUpdateGroupResponse();
         var response = _mediator.Send(createUpdateGroupRequest).Result;
         if (response == 1)
         {
             createUpdateGroupResponse.GroupId = createUpdateGroupRequest.GroupId;
             createUpdateGroupResponse.Message = "Operation Successfull";
             return(Ok(createUpdateGroupResponse));
         }
         else
         {
             createUpdateGroupResponse.GroupId = 0;
             createUpdateGroupResponse.Message = "Not Authorized or Group not found";
             return(BadRequest(createUpdateGroupResponse));
         }
     }
     catch (Exception ex)
     {
         _exceptionHandler.ErrorCode    = "1000";
         _exceptionHandler.ErrorMessage = ex.Message;
         return(BadRequest(_exceptionHandler));
     }
 }
コード例 #2
0
 public async Task <IActionResult> CreateGroup([FromBody] CreateUpdateGroupRequest createUpdateGroupRequest)
 {
     try
     {
         Helper helper = new Helper(_configuration);
         createUpdateGroupRequest.GroupId = -1;
         CreateUpdateGroupResponse createUpdateGroupResponse = new CreateUpdateGroupResponse();
         var response = _mediator.Send(createUpdateGroupRequest).Result;
         if (response == -1)
         {
             return(BadRequest(new { message = "Operation Failure as Group with same name already exists." }));
         }
         createUpdateGroupResponse.GroupId = response;
         return(Ok(createUpdateGroupResponse));
     }
     catch (Exception ex)
     {
         _exceptionHandler.ErrorCode    = "1000";
         _exceptionHandler.ErrorMessage = ex.Message;
         return(BadRequest(_exceptionHandler));
     }
 }