public ActionResult Index(int id, FormCollection collection)
        {
            try
            {
                CidadeModel model = new CidadeModel();
                model.IdCidade = id;
                model.IdEstado = Int32.Parse(collection["IdEstado"]);
                model.Nome = collection["Nome"];
                model.Capital = Boolean.Parse(collection["Capital"]);

                if (model.IdEstado != 0 && !model.Nome.Equals(string.Empty))
                {

                    SerializarCidade(model, true);

                    return ResultMessage();
                }
                else
                {
                    throw new Exception("[Nome] ou [Estado]");
                }
            }
            catch (Exception ex)
            {
                return FailMessage("Dados inválidos." + ex.Message);
            }
        }
        public ActionResult Add(CidadeModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    SerializarCidade(model, false);

                    return ResultMessage();
                }
                catch (Exception ex)
                {
                    return FailMessage(ex.Message);
                }
            }
            else
            {
                return FailMessage("Dados inválidos!");
            }
        }
        private void SerializarCidade(CidadeModel cidade, bool update)
        {
            try
            {
                string path = pathToSerialize + "\\" + cidade.IdCidade + ".txt";

                if (!update && System.IO.File.Exists(path))
                    throw new Exception("Para atualizar utilize o método PUT.");
                else
                {
                    using (TextWriter stream = new StreamWriter(path))
                    {
                        XmlSerializer serializer = new XmlSerializer(typeof(CidadeModel));
                        serializer.Serialize(stream, cidade);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }