Ejemplo n.º 1
0
        public BusMessageModel Edit(BusCategoryModel model)
        {
            if (IsExists(model.BusCategoryId, model.BusCategoryName) == false)
            {
                var obj = _ent.Bus_Categories.Where(x => x.BusCategoryId == model.BusCategoryId).FirstOrDefault();
                if (obj != null)
                {
                    obj.BusCategoryName = model.BusCategoryName;
                    _ent.ApplyCurrentValues(obj.EntityKey.EntitySetName, obj);
                    _ent.SaveChanges();
                    _res.ActionMessage = String.Format(Resources.Message.SuccessfullyUpdated, "Bus Category ");
                    _res.MsgNumber     = 0;
                    _res.MsgStatus     = true;
                }
                else
                {
                    _res.ActionMessage = String.Format(Resources.Message.InvalidOperation, "Bus Category ");
                    _res.MsgNumber     = 1005;
                    _res.ErrSource     = "DataBase";
                    _res.MsgType       = 3;
                    _res.MsgStatus     = true;
                }
            }
            else
            {
                _res.ActionMessage = String.Format(Resources.Message.AlreadyExist, "Bus Category ");
                _res.MsgNumber     = 1001;
                _res.ErrSource     = "DataBase";
                _res.MsgType       = 3;
                _res.MsgStatus     = true;
            }


            return(_res);
        }
Ejemplo n.º 2
0
        public BusMessageModel Create(BusCategoryModel model)
        {
            if (IsExists(model.BusCategoryId, model.BusCategoryName) == false)
            {
                TravelPortalEntity.Bus_Categories obj = new TravelPortalEntity.Bus_Categories
                {
                    BusCategoryName = model.BusCategoryName,
                };
                _ent.AddToBus_Categories(obj);
                _ent.SaveChanges();
                _res.ActionMessage = String.Format(Resources.Message.SuccessfullyCreated, "Bus Category ");
                _res.ErrSource     = "DataBase";
                _res.MsgType       = 0;
                _res.MsgNumber     = 0;
                _res.MsgStatus     = true;
            }
            else
            {
                _res.ActionMessage = String.Format(Resources.Message.AlreadyExist, "Bus Category ");
                _res.MsgNumber     = 1001;
                _res.ErrSource     = "DataBase";
                _res.MsgType       = 3;
                _res.MsgStatus     = true;
            }

            return(_res);
        }
Ejemplo n.º 3
0
        public BusCategoryModel Detail(int?Pid)
        {
            BusCategoryModel model = new BusCategoryModel();

            if (Pid != null)
            {
                var result = _ent.Bus_Categories.Where(x => x.BusCategoryId == Pid).FirstOrDefault();
                if (result != null)
                {
                    model.BusCategoryId   = result.BusCategoryId;
                    model.BusCategoryName = result.BusCategoryName;
                }
                else
                {
                    _res.ActionMessage = String.Format(Resources.Message.InvalidOperation, "Bus Category ");
                    _res.MsgNumber     = 1005;
                    _res.ErrSource     = "DataBase";
                    _res.MsgType       = 3;
                    _res.MsgStatus     = true;
                }
            }
            else
            {
                _res.ActionMessage = String.Format(Resources.Message.InvalidOperation, "Bus Category ");
                _res.MsgNumber     = 1005;
                _res.ErrSource     = "DataBase";
                _res.MsgType       = 3;
                _res.MsgStatus     = true;
            }
            model.Message = _res;
            return(model);
        }
Ejemplo n.º 4
0
        public ActionResult Create()
        {
            BusCategoryModel      _model = new BusCategoryModel();
            BusCategoryRepository _rep   = new BusCategoryRepository();

            _model.Message = _res;
            return(View(_model));
        }
Ejemplo n.º 5
0
        public ActionResult Edit(int?id)
        {
            BusCategoryModel      _model = new BusCategoryModel();
            BusCategoryRepository _rep   = new BusCategoryRepository();

            try
            {
                _model = _rep.Detail(id);
            }
            catch (Exception ex)
            {
                _model.Message = BusGeneralRepository.CatchException(ex);
            }
            BusGeneralRepository.ActionMessage = _model.Message;
            return(View(_model));
        }
Ejemplo n.º 6
0
        public ActionResult Index(int?page)
        {
            BusCategoryModel      _model = new BusCategoryModel();
            BusCategoryRepository _rep   = new BusCategoryRepository();

            BusGeneralRepository.SetRequestPageRow();
            try
            {
                _model.TabularList = _rep.GetPagedList(page);
            }
            catch (Exception ex)
            {
                _model.Message = BusGeneralRepository.CatchException(ex);
            }
            _model.Message = _res;
            return(View(_model));
        }
Ejemplo n.º 7
0
        public ActionResult Delete(int?id)
        {
            BusCategoryModel      _model = new BusCategoryModel();
            BusCategoryRepository _rep   = new BusCategoryRepository();

            try
            {
                _model.Message = _rep.Delete(id);
            }
            catch (Exception ex)
            {
                _model.Message = BusGeneralRepository.CatchException(ex);
            }

            BusGeneralRepository.ActionMessage = _model.Message;
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 8
0
        public IEnumerable <BusCategoryModel> List()
        {
            var _res = _ent.Bus_Categories.OrderBy(x => x.BusCategoryName);
            List <BusCategoryModel> model = new List <BusCategoryModel>();

            foreach (var items in _res)
            {
                BusCategoryModel obj = new BusCategoryModel
                {
                    SNo             = Sno++,
                    BusCategoryId   = items.BusCategoryId,
                    BusCategoryName = items.BusCategoryName,
                };
                model.Add(obj);
            }
            return(model.AsEnumerable());
        }
Ejemplo n.º 9
0
        public ActionResult Edit(BusCategoryModel model)
        {
            BusCategoryRepository _rep = new BusCategoryRepository();

            try
            {
                model.Message = _rep.Edit(model);
            }
            catch (Exception ex)
            {
                model.Message = BusGeneralRepository.CatchException(ex);
            }
            if (model.Message.MsgNumber == 0)
            {
                BusGeneralRepository.ActionMessage = model.Message;
                return(RedirectToAction("Index"));
            }
            else
            {
                return(View(model));
            }
        }
Ejemplo n.º 10
0
        public ActionResult Create(BusCategoryModel model)
        {
            BusCategoryModel      _model = new BusCategoryModel();
            BusCategoryRepository _rep   = new BusCategoryRepository();

            try
            {
                _model.Message = _rep.Create(model);
            }
            catch (Exception ex)
            {
                _model.Message = BusGeneralRepository.CatchException(ex);
            }
            BusGeneralRepository.ActionMessage = _res;
            if (_model.Message.MsgNumber == 0)
            {
                return(RedirectToAction("Index"));
            }
            else
            {
                return(View(model));
            }
        }