Ejemplo n.º 1
0
        public IActionResult UpdateAccountingClass([FromBody] AccountingClass accountingClasess)
        {
            if (accountingClasess == null)
            {
                return(Ok(new APIResponse {
                    status = APIStatus.FAIL.ToString(), response = $"{nameof(accountingClasess)} cannot be null"
                }));
            }

            try
            {
                AccountingClass result = AccountClassHelper.UpdateAccountingClass(accountingClasess);
                if (result != null)
                {
                    return(Ok(new APIResponse {
                        status = APIStatus.PASS.ToString(), response = accountingClasess
                    }));
                }

                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
                }));
            }
        }
Ejemplo n.º 2
0
        public IActionResult DeleteAccountingClass(string code)
        {
            if (string.IsNullOrWhiteSpace(code))
            {
                return(Ok(new APIResponse {
                    status = APIStatus.FAIL.ToString(), response = $"{nameof(code)} cannot be null"
                }));
            }

            try
            {
                AccountingClass result = AccountClassHelper.DeleteAccountingClass(code);
                if (result != null)
                {
                    return(Ok(new APIResponse {
                        status = APIStatus.PASS.ToString(), response = code
                    }));
                }

                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
                }));
            }
        }
Ejemplo n.º 3
0
        public static AccountingClass UpdateAccountingClass(AccountingClass accountingClass)
        {
            try
            {
                using Repository <AccountingClass> repo = new Repository <AccountingClass>();
                repo.AccountingClass.Update(accountingClass);
                if (repo.SaveChanges() > 0)
                {
                    return(accountingClass);
                }

                return(null);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 4
0
        public IActionResult RegisterAccountingClass([FromBody] AccountingClass accountingClass)
        {
            if (accountingClass == null)
            {
                return(Ok(new APIResponse()
                {
                    status = APIStatus.FAIL.ToString(), response = $"{nameof(accountingClass)} can not be null"
                }));
            }

            try
            {
                string errorMsg = string.Empty;
                var    result   = AccountClassHelper.RegisterAccountingClass(accountingClass, out errorMsg);
                if (result != null)
                {
                    return(Ok(new APIResponse()
                    {
                        status = APIStatus.PASS.ToString(), response = result
                    }));
                }
                else
                {
                    if (string.IsNullOrEmpty(errorMsg))
                    {
                        errorMsg = " Registration Failed";
                    }

                    return(Ok(new APIResponse()
                    {
                        status = APIStatus.FAIL.ToString(), response = errorMsg
                    }));
                }
            }
            catch (Exception ex)
            {
                return(Ok(new APIResponse()
                {
                    status = APIStatus.FAIL.ToString(), response = ex.Message
                }));
            }
        }
Ejemplo n.º 5
0
        public static AccountingClass RegisterAccountingClass(AccountingClass accountingClass, out string errorMsg)
        {
            try
            {
                errorMsg = string.Empty;
                using Repository <AccountingClass> repo = new Repository <AccountingClass>();
                //var record = repo.AccountingClass.OrderByDescending(x => x.AddDate).FirstOrDefault();

                //if (record != null)
                //{
                //    accountingClass.Code = CommonHelper.IncreaseCode(record.Code);
                //}
                //else
                //    accountingClass.Code = "1";


                if (GetAccountingClassList(accountingClass.Code).Count > 0)
                {
                    errorMsg = "Code already exists";
                    return(null);
                }
                accountingClass.Active  = "Y";
                accountingClass.AddDate = DateTime.Now;
                repo.AccountingClass.Add(accountingClass);
                if (repo.SaveChanges() > 0)
                {
                    return(accountingClass);
                }

                return(null);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }