//------------------------------------------------------------------------------------------------------
        #endregion

        #region /*--------- Update ---------*\
        //------------------------------------------------------------------------------------------------------
        /// <summary>
        /// Converts the object properties to SQL paramters and executes the update procedure.
        /// </summary>
        /// <param name="CountriesObj">Model object.</param>
        /// <returns>The result of update query.</returns>
        //--------------------------------------------------------------------
        public bool Update(CountriesModel CountriesObj)
        {
            bool result = false;
            using (SqlConnection myConnection = GetSqlConnection())
            {
                SqlCommand myCommand = new SqlCommand("[dbo].[Countries_Update]", myConnection);
                myCommand.CommandType = CommandType.StoredProcedure;
                //----------------------------------------------------------------------------------------------
                // Set the parameters
                //----------------------------------------------------------------------------------------------
                
				myCommand.Parameters.Add("@CountryID", SqlDbType.Int, 4).Value = CountriesObj.CountryID;
				myCommand.Parameters.Add("@Code", SqlDbType.NVarChar, 5).Value = CountriesObj.Code;
				myCommand.Parameters.Add("@EnglishName", SqlDbType.NVarChar, 255).Value = CountriesObj.EnglishName;
				myCommand.Parameters.Add("@ArabicName", SqlDbType.NVarChar, 255).Value = CountriesObj.ArabicName;
				myCommand.Parameters.Add("@TIMEZONE_H", SqlDbType.Int, 4).Value = CountriesObj.TIMEZONE_H;
				myCommand.Parameters.Add("@TIMEZONE_M", SqlDbType.Int, 4).Value = CountriesObj.TIMEZONE_M;
				myCommand.Parameters.Add("@Reg_ID", SqlDbType.Int, 4).Value = CountriesObj.Reg_ID;
				myCommand.Parameters.Add("@SimpleArName", SqlDbType.NVarChar, 255).Value = CountriesObj.SimpleArName;
				myCommand.Parameters.Add("@SimpleEnName", SqlDbType.NVarChar, 255).Value = CountriesObj.SimpleEnName;

                //----------------------------------------------------------------------------------------------
                // Execute the command
                //----------------------------------------------------------------------------------------------
                myConnection.Open();
                if (myCommand.ExecuteNonQuery() > 0)
                {
                    result = true;
                }
                myConnection.Close();
                return result;
                //----------------------------------------------------------------------------------------------
            }
        }
        public JsonResult SaveCountries(CountriesModel model)
        {
            var resultado = "OK";
            var mensagens = new List <string>();
            var idSalvo   = string.Empty;

            if (!ModelState.IsValid)
            {
                resultado = "AVISO";
                mensagens = ModelState.Values.SelectMany(x => x.Errors).Select(x => x.ErrorMessage).ToList();
            }
            else
            {
                try
                {
                    var id = model.Save();
                    if (id > 0)
                    {
                        idSalvo = id.ToString();
                    }
                    else
                    {
                        resultado = "ERRO";
                    }
                }
                catch (Exception)
                {
                    resultado = "ERRO";
                }
            }

            return(Json(new { Resultado = resultado, Mensagens = mensagens, IdSalvo = idSalvo }));
        }
Exemplo n.º 3
0
 public ActionResult Update(CountriesModel CountriesObj)
 {
     //------------------------------------------
     //Check ModelState
     //------------------------------------------
     if (!ModelState.IsValid)
     {
         return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError, "Invalid data"));
     }
     //------------------------------------------
     try
     {
         bool result = CountriesFactor.Update(CountriesObj);
         if (result == true)
         {
             return(List(1, 25, null, null, null, null));
         }
         else
         {
             return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError, "Saving operation faild"));
         }
     }
     catch (Exception ex)
     { return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError, ex.Message)); }
 }
        public ActionResult EditCountry(long id)
        {
            ViewBag.ActiveURL = "/Admin/Countries";
            CountriesModel model = objAPI.GetObjectByKey <CountriesModel>("configuration", "countriesbyid", id.ToString(), "id");

            return(View(model));
        }
Exemplo n.º 5
0
        public AdministrationPanel(User userConnected)
        {
            InitializeComponent();

            _userConnected   = userConnected;
            Registry.USER_ID = userConnected.Id.ToString();

            UsersModel usersModel = new UsersModel();

            _users = usersModel.GetAll <User>();

            CompetitionsModel competitionsModel = new CompetitionsModel();

            _competitions = competitionsModel.GetAll <Competition>();

            ShootersModel shootersModel = new ShootersModel();

            _shooters = shootersModel.GetAll <Shooter>();

            CountriesModel countriesModel = new CountriesModel();

            _countries = countriesModel.GetAll <Country>();

            Fullname.DataContext          = _userConnected;
            ImgProfilePicture.DataContext = _userConnected;

            Main.Content = new Views.Index(_shooters, _competitions);
        }
Exemplo n.º 6
0
        private async Task GotoDetailScreen()
        {
            CountriesModel _selectedItem = SelectedItem;

            Application.Current.Properties["SelectedCountryValue"] = JsonConvert.SerializeObject(SelectedItem);
            await Application.Current.SavePropertiesAsync();

            await PushAsync <CountryDetailsPageModel>();
        }
Exemplo n.º 7
0
        //------------------------------------------------------------------------------------------------------
        #endregion

        #region --------------GetObject--------------
        //------------------------------------------------------------------------------------------------------
        /// <summary>
        /// Gets the spesific record.
        /// </summary>
        /// <param name="ID">The model id.</param>
        /// <returns>Model object.</returns>
        //--------------------------------------------------------------------
        public static CountriesModel GetObject(int CountryID)
        {
            CountriesModel        CountriesObj = null;
            List <CountriesModel> list         = CountriesSqlDataPrvider.Instance.Get(CountryID);

            if (list != null && list.Count > 0)
            {
                CountriesObj = list[0];
            }
            return(CountriesObj);
        }
Exemplo n.º 8
0
        // GET
        public IActionResult Index()
        {
            var model = new CountriesModel("Countries - Mustache example");

            model.Codes.Add("FR");
            model.Codes.Add("IT");
            model.Codes.Add("US");
            model.Codes.Add("CA");
            model.Codes.Add("UK");
            return(View(model));
        }
 public ActionResult EditCountry(CountriesModel model)
 {
     ViewBag.ActiveURL = "/Admin/Countries";
     if (ModelState.IsValid)
     {
         string jsonStr = JsonConvert.SerializeObject(model);
         TempData["ErrMsg"] = objAPI.PostRecordtoApI("configuration", "addEditCountries", jsonStr);
         return(RedirectToAction("index", "Countries", new { Area = "Admin" }));
     }
     return(View(model));
 }
Exemplo n.º 10
0
        public HttpResponseMessage Put(int id, CountriesModel country)
        {
            Country dbEntry = context.Countries.Find(id);

            byte[] imageBytes = Convert.FromBase64String(country.ImagePath);
            dbEntry.Description = country.Description;
            dbEntry.Name        = country.Name;
            dbEntry.ImageData   = imageBytes;
            context.SaveChanges();
            return(Request.CreateResponse(
                       HttpStatusCode.Created));
        }
Exemplo n.º 11
0
        public HttpResponseMessage Post(CountriesModel country)
        {
            byte[]  imageBytes = Convert.FromBase64String(country.ImagePath);
            Country newCountry = new Country();

            newCountry.Description = country.Description;
            newCountry.Name        = country.Name;
            newCountry.ImageData   = imageBytes;
            context.Countries.Add(newCountry);
            context.SaveChanges();
            return(Request.CreateResponse(
                       HttpStatusCode.Created));
        }
        public ActionResult Index()
        {
            ViewBag.ListaTamPag             = new SelectList(new int[] { _quantMaxLinhasPorPagina, 10, 15, 20 }, _quantMaxLinhasPorPagina);
            ViewBag.QuantMaxLinhasPorPagina = _quantMaxLinhasPorPagina;
            ViewBag.PaginaAtual             = 1;

            var lista = CountriesModel.RecoverList(ViewBag.PaginaAtual, _quantMaxLinhasPorPagina);
            var quant = CountriesModel.RecoverQuantity();

            var difQuantPaginas = (quant % ViewBag.QuantMaxLinhasPorPagina) > 0 ? 1 : 0;

            ViewBag.QuantPaginas = (quant / ViewBag.QuantMaxLinhasPorPagina) + difQuantPaginas;

            return(View(lista));
        }
Exemplo n.º 13
0
 public ActionResult GetObject(int id)
 {
     try
     {
         CountriesModel CountriesObj = CountriesFactor.GetObject(id);
         if (CountriesObj == null)
         {
             CountriesObj = new CountriesModel();
         }
         return(Json(CountriesObj, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError, ex.Message));
     }
 }
Exemplo n.º 14
0
        // GET: Countries
        public ActionResult Index(string countryName = "", int page = 1)
        {
            int rowCount = 0;
            var model    = new CountriesModel
            {
                ListCountries = new Countries {
                    CountryName = countryName
                }.GetPage(string.Empty, string.Empty, string.Empty, CmsConstants.RowAmount20, page > 0?page - 1:page, ref rowCount),
                RowCount   = rowCount,
                Pagination = new PaginationModel
                {
                    TotalPage = rowCount,
                    PageSize  = CmsConstants.RowAmount20,
                    LinkLimit = 5,
                    PageIndex = page
                }
            };

            return(View(model));
        }
Exemplo n.º 15
0
 public HttpResponseMessage Put(Guid id, [FromBody] CountriesModel item)
 {
     _process.Save(item.Token, item.CountryId, item.IsActive, item.Country, item.Code, UpdatedId);
     return(new HttpResponseMessage(HttpStatusCode.OK));
 }
 public JsonResult RecuperarCountries(int id)
 {
     return(Json(CountriesModel.RecoverById(id)));
 }
        //------------------------------------------------------------------------------------------------------
        #endregion

        #region /*--------- PopulateModelFromIDataReader ---------*\
        //------------------------------------------------------------------------------------------------------
        /// <summary>
        /// Populates model from IDataReader .
        /// </summary>
        /// <param name="reader"></param>
        /// <returns>Model object.</returns>
        //--------------------------------------------------------------------
        private CountriesModel PopulateModelFromIDataReader(IDataReader reader)
        {
            //Create a new object
            CountriesModel CountriesObj = new CountriesModel();
            //Fill the object with data

			//------------------------------------------------
			//[CountryID]
			//------------------------------------------------
			if (reader["CountryID"] != DBNull.Value)
			    CountriesObj.CountryID = (int)reader["CountryID"];
			//------------------------------------------------
			//------------------------------------------------
			//[Code]
			//------------------------------------------------
			if (reader["Code"] != DBNull.Value)
			    CountriesObj.Code = (string)reader["Code"];
			//------------------------------------------------
			//------------------------------------------------
			//[EnglishName]
			//------------------------------------------------
			if (reader["EnglishName"] != DBNull.Value)
			    CountriesObj.EnglishName = (string)reader["EnglishName"];
			//------------------------------------------------
			//------------------------------------------------
			//[ArabicName]
			//------------------------------------------------
			if (reader["ArabicName"] != DBNull.Value)
			    CountriesObj.ArabicName = (string)reader["ArabicName"];
			//------------------------------------------------
			//------------------------------------------------
			//[TIMEZONE_H]
			//------------------------------------------------
			if (reader["TIMEZONE_H"] != DBNull.Value)
			    CountriesObj.TIMEZONE_H = (int)reader["TIMEZONE_H"];
			//------------------------------------------------
			//------------------------------------------------
			//[TIMEZONE_M]
			//------------------------------------------------
			if (reader["TIMEZONE_M"] != DBNull.Value)
			    CountriesObj.TIMEZONE_M = (int)reader["TIMEZONE_M"];
			//------------------------------------------------
			//------------------------------------------------
			//[Reg_ID]
			//------------------------------------------------
			if (reader["Reg_ID"] != DBNull.Value)
			    CountriesObj.Reg_ID = (int)reader["Reg_ID"];
			//------------------------------------------------
			//------------------------------------------------
			//[SimpleArName]
			//------------------------------------------------
			if (reader["SimpleArName"] != DBNull.Value)
			    CountriesObj.SimpleArName = (string)reader["SimpleArName"];
			//------------------------------------------------
			//------------------------------------------------
			//[SimpleEnName]
			//------------------------------------------------
			if (reader["SimpleEnName"] != DBNull.Value)
			    CountriesObj.SimpleEnName = (string)reader["SimpleEnName"];
			//------------------------------------------------
            //Return the populated object
            return CountriesObj;
        }
        public JsonResult CountriesPagina(int page, int tamPag, string order)
        {
            var lista = CountriesModel.RecoverList(page, tamPag, order: order);

            return(Json(lista));
        }
Exemplo n.º 19
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            CountriesModel countriesModel = new CountriesModel();

            return(countriesModel.GetFlagPicture((int)value));
        }
Exemplo n.º 20
0
        //------------------------------------------------------------------------------------------------------
        #endregion

        #region --------------Update--------------
        //------------------------------------------------------------------------------------------------------
        /// <summary>
        /// Updates model object by calling sql data provider update method.
        /// </summary>
        /// <param name="CountriesObj">The model object.</param>
        /// <returns>The result of update operation.</returns>
        //--------------------------------------------------------------------
        public static bool Update(CountriesModel CountriesObj)
        {
            return(CountriesSqlDataPrvider.Instance.Update(CountriesObj));
        }
 public JsonResult ExcluirCountries(int id)
 {
     return(Json(CountriesModel.ExcludeId(id)));
 }