コード例 #1
0
ファイル: SaleTax.cs プロジェクト: tmrconsultweb/TMRC-CSP
        public string Save(Models.SaleTax _s, int ResellerId = 0)
        {
            try
            {
                var db = new Context.ConnectionStringsContext();

                if (_s.Id != 0 && db.SaleTax.Any(m => m.Id == _s.Id))  //Update
                {
                    var saletax = db.SaleTax.Where(m => m.Id == _s.Id).SingleOrDefault();
                    saletax.Amount     = _s.Amount;
                    saletax.ResellerId = ResellerId;
                    saletax.Country    = _s.Country;
                    saletax.State      = _s.State;
                }
                else  //Save
                {
                    Models.SaleTax saletax = new Models.SaleTax
                    {
                        Amount     = _s.Amount,
                        Status     = true,
                        ResellerId = ResellerId,
                        Country    = _s.Country,
                        State      = _s.State,
                    };
                    db.SaleTax.Add(saletax);
                }
                db.SaveChanges();
                return("Successully sale tax has been saved.");
            }
            catch (Exception ex)
            {
                return("Unknown error occur, Please try again.");
            }
        }
コード例 #2
0
ファイル: SaleTax.cs プロジェクト: tmrconsultweb/TMRC-CSP
        public Models.SaleTax Get(string Country, string state, int ResellerId = 0)
        {
            try
            {
                var db = new Context.ConnectionStringsContext();

                var data = (from s in db.SaleTax
                            join c in db.Countries
                            on s.Country equals c.Code
                            where s.Status == true && c.Status == true &&
                            s.Country == Country && s.State.ToLower() == state.ToLower()
                            select new
                {
                    s.Amount,
                    s.State,
                    Country = c.CountryName,
                    CountryCode = c.Code,
                    s.Id
                }).SingleOrDefault();
                Models.SaleTax list = new Models.SaleTax
                {
                    Amount  = data.Amount,
                    Country = data.Country,
                    State   = data.State,
                    Id      = data.Id
                };
                return(list);
            }
            catch
            {
                return(new Models.SaleTax());
            }
        }
コード例 #3
0
 public ActionResult SaleTax()
 {
     ViewModel.Countries.Countries country = new ViewModel.Countries.Countries();
     ViewBag.Countries = country.GetCountries();
     Models.SaleTax saleTax = new Models.SaleTax
     {
         Id = 0
     };
     return(View(saleTax));
 }
コード例 #4
0
 public ActionResult SaleTax(Models.SaleTax _s)
 {
     ViewModel.Countries.Countries country = new ViewModel.Countries.Countries();
     ViewBag.Countries = country.GetCountries();
     if (ModelState.IsValid)
     {
         ViewModel.SaleTax.SaleTax saleTax = new ViewModel.SaleTax.SaleTax();
         ViewBag.msg = saleTax.Save(_s, 0); //0 means it's Admin
     }
     return(View());
 }