Ejemplo n.º 1
0
        public ActionResult InsertVehicleTrim(VehicleTrim item)
        {
            Entities _ctx = new Entities();

            try
            {
                if (ModelState.IsValid)
                {
                    item.VehicleTrimID = Guid.NewGuid();
                    item.CreatedOn     = DateTime.Now;
                    _ctx.VehicleTrims.Add(item);
                    _ctx.SaveChanges();
                }
                else
                {
                    return(RedirectToAction("NewVehicleTrim", "Definitions"));
                }
            }
            catch (Exception ex)
            {
                functionHelper.InsertErrorLog(ex, "InsertVehicleTrim", "Definitions");
            }
            TempData["InsertVehicleTrimMessage"] = "Vehicle Trim inserted successfully";
            return(RedirectToAction("VehicleTrim", "Definitions"));
        }
Ejemplo n.º 2
0
        public ActionResult EditVehicleTrim(string id)
        {
            Entities    _ctx = new Entities();
            VehicleTrim _itm = null;

            try
            {
                Guid guidItem = new Guid(id);
                _itm = (from vtm in _ctx.VehicleTrims
                        where vtm.VehicleTrimID == guidItem
                        select vtm).FirstOrDefault();

                List <Model> _lstModel = new List <Model>();
                List <Make>  _lstMake  = new List <Make>();
                _lstModel = (from mdl in _ctx.Models
                             where mdl.IsActive == true &&
                             mdl.IsDeleted == false
                             select mdl).OrderBy(obj => obj.Name).ToList();
                _lstMake = (from mke in _ctx.Makes
                            where mke.IsActive == true &&
                            mke.IsDeleted == false
                            select mke).OrderBy(obj => obj.Name).ToList();
                if (_lstModel != null)
                {
                    ViewBag.ModelList = _lstModel;
                }
                if (_lstMake != null)
                {
                    ViewBag.MakeList = _lstMake;
                }
            }
            catch (Exception ex)
            {
                functionHelper.InsertErrorLog(ex, "EditVehicleTrim", "Definitions");
            }
            return(View(_itm));
        }
Ejemplo n.º 3
0
        public ActionResult NewVehicleTrim()
        {
            VehicleTrim _itm = new VehicleTrim();

            _itm.IsActive  = true;
            _itm.IsDeleted = false;

            try
            {
                Entities     _ctx      = new Entities();
                List <Model> _lstModel = new List <Model>();
                List <Make>  _lstMake  = new List <Make>();
                _lstModel = (from mdl in _ctx.Models
                             where mdl.IsActive == true &&
                             mdl.IsDeleted == false
                             select mdl).OrderBy(obj => obj.Name).ToList();
                _lstMake = (from mke in _ctx.Makes
                            where mke.IsActive == true &&
                            mke.IsDeleted == false
                            select mke).OrderBy(obj => obj.Name).ToList();
                if (_lstModel != null)
                {
                    ViewBag.ModelList = _lstModel;
                }
                if (_lstMake != null)
                {
                    ViewBag.MakeList = _lstMake;
                }
            }
            catch (Exception ex)
            {
                functionHelper.InsertErrorLog(ex, "NewVehicleTrim", "Definitions");
            }

            return(View(_itm));
        }