示例#1
0
        public static TaxMasters UpdateTaxMaster(TaxMasters taxMaster)
        {
            try
            {
                using Repository <TaxMasters> repo = new Repository <TaxMasters>();
                repo.TaxMasters.Update(taxMaster);
                if (repo.SaveChanges() > 0)
                {
                    return(taxMaster);
                }

                return(null);
            }
            catch { throw; }
        }
示例#2
0
        //public static List<TaxMasters> GetListOfInputTaxs()
        //{
        //  try
        //  {
        //    using (Repository<TaxMasters> repo = new Repository<TaxMasters>())
        //    {
        //      return repo.TaxMasters
        //                 .AsEnumerable()
        //                 .Where(t => t.Active.Equals("Y", StringComparison.OrdinalIgnoreCase)
        //                          && t.TaxType == "INPUT").ToList();
        //    }
        //  }
        //  catch { throw; }
        //}

        //public static List<TaxMasters> GetListOfOutputTaxs()
        //{
        //  try
        //  {
        //    using (Repository<TaxMasters> repo = new Repository<TaxMasters>())
        //    {
        //      return repo.TaxMasters
        //                 .AsEnumerable()
        //                 .Where(t => t.Active.Equals("Y", StringComparison.OrdinalIgnoreCase)
        //                          && t.TaxType == "OUTPUT").ToList();
        //    }
        //  }
        //  catch { throw; }
        //}


        public static TaxMasters RegisterTaxMaster(TaxMasters taxMaster)
        {
            try
            {
                using Repository <TaxMasters> repo = new Repository <TaxMasters>();
                taxMaster.Active = "Y";
                repo.TaxMasters.Add(taxMaster);
                if (repo.SaveChanges() > 0)
                {
                    return(taxMaster);
                }

                return(null);
            }
            catch { throw; }
        }
示例#3
0
        public async Task <IActionResult> RegisterTaxMasters([FromBody] TaxMasters taxmaster)
        {
            var result = await Task.Run(() =>
            {
                if (taxmaster == null)
                {
                    return(Ok(new APIResponse()
                    {
                        status = APIStatus.FAIL.ToString(), response = "Request cannot be null"
                    }));
                }
                try
                {
                    if (TaxmasterHelper.GetListOfTaxMasters().Where(x => x.Code == taxmaster.Code).Count() > 0)
                    {
                        return(Ok(new APIResponse()
                        {
                            status = APIStatus.FAIL.ToString(), response = $"Tax Master Code {nameof(taxmaster.Code)} is already exists"
                        }));
                    }


                    var result = TaxmasterHelper.RegisterTaxMaster(taxmaster);
                    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
                    }));
                }
            });

            return(result);
        }
示例#4
0
        public async Task <IActionResult> UpdateTaxMaster([FromBody] TaxMasters taxmaster)
        {
            var result = await Task.Run(() =>
            {
                if (taxmaster == null)
                {
                    return(Ok(new APIResponse()
                    {
                        status = APIStatus.FAIL.ToString(), response = $"{nameof(taxmaster)} cannot be null"
                    }));
                }

                try
                {
                    var result = TaxmasterHelper.UpdateTaxMaster(taxmaster);
                    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
                    }));
                }
            });

            return(result);
        }