Beispiel #1
0
        public async Task <IActionResult> RegisterTank([FromBody] TblTanks tanks)
        {
            var result = await Task.Run(() =>
            {
                APIResponse apiResponse = null;
                if (tanks == null)
                {
                    return(Ok(new APIResponse()
                    {
                        status = APIStatus.PASS.ToString(), response = "object can not be null"
                    }));
                }

                try
                {
                    var tanklist = new TankHelpers().GetList(tanks.TankNo);
                    if (tanklist.Count() > 0)
                    {
                        return(Ok(new APIResponse()
                        {
                            status = APIStatus.PASS.ToString(), response = $"tank Code {nameof(tanklist)} is already exists ,Please Use Different Code "
                        }));
                    }
                    var result = new TankHelpers().Register(tanks);
                    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
                    }));
                }
            });

            return(result);
        }
Beispiel #2
0
        public async Task <IActionResult> GetTankList()
        {
            var result = await Task.Run(() =>
            {
                var tankList = new TankHelpers().GetList();
                if (tankList.Count() > 0)
                {
                    dynamic expdoObj  = new ExpandoObject();
                    expdoObj.tankList = tankList;
                    return(Ok(new APIResponse {
                        status = APIStatus.PASS.ToString(), response = expdoObj
                    }));
                }
                else
                {
                    return(Ok(new APIResponse {
                        status = APIStatus.FAIL.ToString(), response = "No Data Found."
                    }));
                }
            });

            return(result);
        }