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);
        }
        public string UpdateCategory()
        {
            string result = "Failed";

            BusApi.BusApiClient       _api = new BusApi.BusApiClient();
            BusApi.BusCategoryRequest _req = new BusApi.BusCategoryRequest();
            _req.Auth            = BusGeneralProvider.AAuth;
            _req.MaxResult       = 10000;
            _req.BusCatagoryName = "";
            _req.BusOperatorCode = "";

            var onlineresult = _api.CategoryList(_req);

            if (onlineresult != null && onlineresult.List.Any())
            {
                var localresult = _ent.Bus_Categories;
                foreach (var item in onlineresult.List)
                {
                    bool addnew = true;

                    foreach (var localitem in localresult)
                    {
                        if (item.CategoryId == localitem.CategoryCode)
                        {
                            // edit data....
                            var editData = _ent.Bus_Categories.FirstOrDefault(x => x.CategoryCode == item.CategoryId);
                            editData.BusCategoryName = item.CatagoryName;
                            editData.OperatoCode     = item.OperatorId;
                            _ent.ApplyCurrentValues(editData.EntityKey.EntitySetName, editData);
                            //_ent.SaveChanges();
                            addnew = false;
                        }
                    }
                    if (addnew == true)
                    {
                        //add data....
                        TravelPortalEntity.Bus_Categories obj = new TravelPortalEntity.Bus_Categories
                        {
                            BusCategoryName = item.CatagoryName,
                            CategoryCode    = item.CategoryId,
                            OperatoCode     = item.OperatorId
                        };
                        _ent.AddToBus_Categories(obj);
                        //_ent.SaveChanges();
                    }
                }
                _ent.SaveChanges();
                result = "Updated";
            }

            return(result);
        }