public IActionResult DeleteGLSubCode(string code)
        {
            if (string.IsNullOrWhiteSpace(code))
            {
                return(Ok(new APIResponse()
                {
                    status = APIStatus.PASS.ToString(), response = $"{nameof(code)} cannot be null"
                }));
            }

            try
            {
                GlsubCode result = GLHelper.DeleteGLSubCode(code);
                if (result != null)
                {
                    return(Ok(new APIResponse()
                    {
                        status = APIStatus.PASS.ToString(), response = result
                    }));
                }

                return(Ok(new APIResponse()
                {
                    status = APIStatus.FAIL.ToString(), response = "Deletion failed."
                }));
            }
            catch (Exception ex)
            {
                return(Ok(new APIResponse()
                {
                    status = APIStatus.FAIL.ToString(), response = ex.Message
                }));
            }
        }
        public IActionResult UpdateGLSubCode([FromBody] GlsubCode subcode)
        {
            if (subcode == null)
            {
                return(Ok(new APIResponse()
                {
                    status = APIStatus.PASS.ToString(), response = $"{nameof(subcode)} cannot be null"
                }));
            }

            try
            {
                GlsubCode result = GLHelper.UpdateGLSubCode(subcode);
                if (result != null)
                {
                    return(Ok(new APIResponse()
                    {
                        status = APIStatus.PASS.ToString(), response = result
                    }));
                }

                return(Ok(new APIResponse()
                {
                    status = APIStatus.FAIL.ToString(), response = "Updation failed."
                }));
            }
            catch (Exception ex)
            {
                return(Ok(new APIResponse()
                {
                    status = APIStatus.FAIL.ToString(), response = ex.Message
                }));
            }
        }
Exemple #3
0
        public static GlsubCode UpdateGLSubCode(GlsubCode glSubCode)
        {
            try
            {
                using Repository <GlsubCode> repo = new Repository <GlsubCode>();
                repo.GlsubCode.Update(glSubCode);
                if (repo.SaveChanges() > 0)
                {
                    return(glSubCode);
                }

                return(null);
            }
            catch { throw; }
        }
Exemple #4
0
        public static GlsubCode RegisterGLSubCode(GlsubCode glSubCode)
        {
            try
            {
                using Repository <GlsubCode> repo = new Repository <GlsubCode>();
                glSubCode.Active  = "Y";
                glSubCode.AddDate = DateTime.Now;
                repo.GlsubCode.Add(glSubCode);
                if (repo.SaveChanges() > 0)
                {
                    return(glSubCode);
                }

                return(null);
            }
            catch { throw; }
        }
        public IActionResult RegisterGlsubCode([FromBody] GlsubCode glsubcode)
        {
            if (glsubcode == null)
            {
                return(Ok(new APIResponse()
                {
                    status = APIStatus.FAIL.ToString(), response = "Requst can not be empty."
                }));
            }
            try
            {
                if (GLHelper.GetGLSubCodeList(glsubcode.SubCode).Count > 0)
                {
                    return(Ok(new APIResponse()
                    {
                        status = APIStatus.FAIL.ToString(), response = $"Code ={glsubcode.SubCode} alredy exists."
                    }));
                }

                GlsubCode result = GLHelper.RegisterGLSubCode(glsubcode);
                if (result != null)
                {
                    return(Ok(new APIResponse()
                    {
                        status = APIStatus.PASS.ToString(), response = result
                    }));
                }

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