Exemplo n.º 1
0
 public IActionResult GetDivisionsList()
 {
     try
     {
         var divisionsList = DivisionHelper.GetList();
         if (divisionsList.Count() > 0)
         {
             dynamic expdoObj = new ExpandoObject();
             expdoObj.divisionsList = divisionsList;
             return(Ok(new APIResponse {
                 status = APIStatus.PASS.ToString(), response = expdoObj
             }));
         }
         else
         {
             return(Ok(new APIResponse {
                 status = APIStatus.FAIL.ToString(), response = "No Data Found."
             }));
         }
     }
     catch (Exception ex)
     {
         return(Ok(new APIResponse()
         {
             status = APIStatus.FAIL.ToString(), response = ex.Message
         }));
     }
 }
Exemplo n.º 2
0
        public IActionResult RegisterDivision([FromBody] Divisions division)
        {
            if (division == null)
            {
                return(Ok(new APIResponse()
                {
                    status = APIStatus.PASS.ToString(), response = "object can not be null"
                }));
            }

            try
            {
                if (DivisionHelper.GetList(division.Code).Count() > 0)
                {
                    return(Ok(new APIResponse()
                    {
                        status = APIStatus.PASS.ToString(), response = $"Division Code {nameof(division.Code)} is already exists ,Please Use Different Code "
                    }));
                }

                var         result = DivisionHelper.Register(division);
                APIResponse apiResponse;
                if (result != null)
                {
                    apiResponse = new APIResponse()
                    {
                        status = APIStatus.PASS.ToString(), response = result
                    };
                }
                else
                {
                    apiResponse = new APIResponse()
                    {
                        status = APIStatus.FAIL.ToString(), response = "Registration Failed."
                    };
                }

                return(Ok(apiResponse));
            }
            catch (Exception ex)
            {
                return(Ok(new APIResponse()
                {
                    status = APIStatus.FAIL.ToString(), response = ex.Message
                }));
            }
        }