Ejemplo n.º 1
0
        public JsonResultEntity Create([FromBody] CountryEntity countryEntity)
        {
            CountryBL        countryBL = new CountryBL();
            JsonResultEntity response  = new JsonResultEntity();

            try
            {
                var result = countryBL.Create(countryEntity);

                if (result.HasWarning())
                {
                    response.Message = String.Join(",", result.Warning);
                    return(response);
                }

                response.Success = true;
                response.Data    = result.Value;
            }
            catch (Exception ex)
            {
                response.Message = ex.Message;
                LoggerHelper.Error(ex);
            }

            return(response);
        }
Ejemplo n.º 2
0
        public ActionResult DetailsPost(CountryDetailsVM objDetailsVM, string Submit, HttpPostedFileBase file)
        {
            CommonBL objCommonBL = null;

            try
            {
                if (Submit == "Save")
                {
                    objCountryBL = new CountryBL();
                    objCommonBL  = new CommonBL();

                    objDetailsVM.CntMstr.Status = 1;
                    //if (file != null)
                    //{
                    //    string path = "~/Content/profileimages/" + Guid.NewGuid() + file.FileName;
                    //    file.SaveAs(Server.MapPath(path));
                    //    //objDetailsVM.User.ImageUrl = path;//.Substring(2, path.Length - 2);
                    //}
                    objResponse = objCountryBL.SaveCountry(objDetailsVM.CntMstr, objDetailsVM.CntMstr.CountryID > 0 ? "U" : "C");
                    //  objDetailsVM.lstUserTypes = objCommonBL.GetCodeDetail(new CodeDetailFilter() { CodeTypeId = 1 });
                    objDetailsVM.Toast = WebCommon.SetToast(objResponse, "Country", "Index");
                }
                return(View(objDetailsVM));
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                objCountryBL = null;
                objDetailsVM = null;
                objCommonBL  = null;
            }
        }
Ejemplo n.º 3
0
        public string GetCountry()
        {
            CountryBL    CBL    = new CountryBL();
            CountryModel CModel = new CountryModel();

            return(CBL.GetCountry(CModel));
        }
Ejemplo n.º 4
0
        public ActionResult Index(CountryMasterFilter objFilter, int?pageNumber)
        {
            CountryMasterListVM empVM = null;

            try
            {
                objCountryBL = new CountryBL();
                if (TempData["CountryFilter"] != null)
                {
                    objFilter           = (CountryMasterFilter)TempData["CountryFilter"];
                    objFilter.CountryID = 0;
                    if (pageNumber != null)
                    {
                        if (pageNumber != 0)
                        {
                            objFilter.PageNumber = pageNumber ?? objFilter.PageNumber;
                        }
                        TempData.Keep("CountryFilter");
                    }
                }
                empVM = GetCountryListVM(objFilter);
                return(View("Index", empVM));
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                empVM        = null;
                objCountryBL = null;
            }
        }
Ejemplo n.º 5
0
        private CountryMasterListVM GetCountryListVM(CountryMasterFilter objFilter)
        {
            //Thread.Sleep(1000);
            //CountryMasterListVM userListVM = null;
            CommonBL objCommonBL = null;

            try
            {
                objCountryBL          = new CountryBL();
                objListVM             = new CountryMasterListVM();
                objCommonBL           = new CommonBL();
                objFilter.PagingRoute = new PagingRoute()
                {
                    Action = "Index", Controller = "Country"
                };
                objListVM.lstCountryMaster = objCountryBL.GetData(objFilter);
                objListVM.lstUserTypes     = objCommonBL.GetCodeDetail(new CodeDetailFilter()
                {
                    CodeTypeId = 1
                });
                objListVM.QueryBO = objListVM.objFilter = objFilter;
                return(objListVM);
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                objListVM = null;
            }
        }
Ejemplo n.º 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            CountryBL objCountryBL = new CountryBL();

            lstCountry = objCountryBL.GetAllCountry(cnt).ToList();
            if (!IsPostBack)
            {
                GetCountry();
                GetState();
            }
        }
Ejemplo n.º 7
0
        protected void GetCountry()
        {
            List <Countrytbl> lstCountry   = new List <Countrytbl>();
            Countrytbl        ctry         = new Countrytbl();
            CountryBL         objcountryBL = new CountryBL();

            lstCountry = objcountryBL.GetAllCountry(ctry).ToList();
            foreach (var cnt in lstCountry)
            {
                ListItem li = new ListItem();
                li.Text  = cnt.CountryName;
                li.Value = cnt.CountryID.ToString();
                DDlCountry.Items.Add(li);
            }
        }
Ejemplo n.º 8
0
        public ActionResult Action(CountryMasterFilter objFilter, string submit)
        {
            CommonBL      objCommonBL = null;
            CountryMaster objCountry  = null;

            try
            {
                objDetailsVM = new CountryDetailsVM();
                if (submit.ToLower() == "edit")
                {
                    objCommonBL = new CommonBL();
                    TempData["CountryFilter"] = objFilter;
                    objCountryBL         = new CountryBL();
                    objDetailsVM         = new CountryDetailsVM();
                    objDetailsVM.CntMstr = objCountryBL.GetData(new CountryMasterFilter()
                    {
                        CountryID = objFilter.CountryID
                    }).FirstOrDefault();
                    // objDetailsVM.lstUserTypes = objCommonBL.GetCodeDetail(new CodeDetailFilter() { CodeTypeId = 1 });
                    return(View("Details", objDetailsVM));
                }
                else if (submit.ToLower() == "delete")
                {
                    objCountryBL          = new CountryBL();
                    objListVM             = new CountryMasterListVM();
                    objCountry            = new CountryMaster(objFilter.CountryID);
                    objCountry.ModifiedBy = 1;
                    objCountry.Remark     = "Deleted";
                    objResponse           = objCountryBL.SaveCountry(objCountry, "D");
                    objFilter.CountryID   = 0;
                    objListVM             = GetCountryListVM(objFilter);
                    objListVM.Toast       = WebCommon.SetToast(objResponse);
                    return(View("Index", objListVM));
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                objCountryBL = null;
                objDetailsVM = null;
                objListVM    = null;
                objCommonBL  = null;
            }
            return(null);
        }
Ejemplo n.º 9
0
        public JsonResultEntity Delete(int id)
        {
            var countryBL             = new CountryBL();
            JsonResultEntity response = new JsonResultEntity();

            try
            {
                var result = countryBL.DeleteById(id);
                if (result.HasWarning())
                {
                    response.Message = String.Join(",", result.Warning);
                    return(response);
                }

                response.Success = true;
                response.Data    = result.Value;
            }
            catch (Exception e)
            {
                response.Message = e.Message;
                LoggerHelper.Error(e);
            }
            return(response);
        }
Ejemplo n.º 10
0
        public override JsonResultEntity Get([FromBody] DBParamEntity dbParamEntity)
        {
            CountryBL        countryBL = new CountryBL();
            JsonResultEntity response  = new JsonResultEntity();

            try
            {
                var result = countryBL.GetAll(dbParamEntity);

                if (result.HasWarning())
                {
                    response.Message = String.Join(",", result.Warning);
                    return(response);
                }

                var dataFound  = countryBL.GetTotalRows(dbParamEntity);
                var totalPages = Convert.ToInt32(Math.Ceiling(dataFound.Value / Convert.ToDouble(dbParamEntity.Limit)));

                response.Success  = true;
                response.Data     = result.Value;
                response.MetaInfo = new MetaInfoEntity
                {
                    DataFound   = dataFound.Value,
                    DataPerPage = dbParamEntity.Limit,
                    Page        = dbParamEntity.Page,
                    TotalPages  = totalPages == 0 ? 1 : totalPages
                };
            }
            catch (Exception ex)
            {
                response.Message = ex.Message;
                LoggerHelper.Error(ex);
            }

            return(response);
        }
Ejemplo n.º 11
0
        static void Main(string[] args)
        {
            CountryBL      queryToCountries = new CountryBL();
            Country        country          = new Country();
            List <Country> listOfCountries  = new List <Country>();

            Console.WriteLine("Consulta a la base de datos (paises)");
            listOfCountries = queryToCountries.GetCountries();

            if (listOfCountries == null && queryToCountries.ErrorMessage != string.Empty)
            {
                Console.WriteLine("Error: {0}", queryToCountries.ErrorMessage);
            }
            else
            {
                foreach (var item in listOfCountries)
                {
                    Console.WriteLine("País : {0}", item.NameEs);
                    Console.WriteLine("ISO2 : {0} - ISO3: {1}", item.ISO2, item.ISO3);
                }
            }

            Console.WriteLine("---------------------------------");
            Console.WriteLine("Agregue un nuevo país.");
            Console.Write("Nombre en español: ");
            country.NameEs = Console.ReadLine();

            Console.Write("Nombre en inglés: ");
            country.NameEn = Console.ReadLine();

            Console.Write("Cód ISO2: ");
            country.ISO2 = Console.ReadLine();

            Console.Write("Cód ISO3: ");
            country.ISO3 = Console.ReadLine();

            bool record = queryToCountries.InsertCountry(country);

            if (record)
            {
                Console.WriteLine("Los datos del país {0} fueron registrados con éxito.", country.NameEs);
            }
            else
            {
                Console.WriteLine("Error en el registro de datos: {0}", queryToCountries.ErrorMessage);
            }

            //Console.Write("Id: ");
            //// Realizar la consulta a BD
            //int idCountry = Convert.ToInt32(Console.ReadLine());
            //country = queryToCountries.GetCountry(idCountry);

            //if (country != null)
            //{
            //    //mostrar el resultado:
            //    Console.WriteLine("El país tiene los siguientes datos: ");
            //    Console.WriteLine("Nombre: {0} - {1}", country.NameEn, country.ISO3);
            //}
            //else
            //    Console.WriteLine("No hay datos");

            Console.ReadLine();
        }
Ejemplo n.º 12
0
        static void Main(string[] args)
        {
            CountryBL  queryToCountries = new CountryBL();
            MusicianBL queryMusician    = new MusicianBL();

            Country        country         = new Country();
            Musician       musician        = new Musician();
            List <Country> listOfCountries = new List <Country>();

            Console.WriteLine("Creación de integrante de agrupación (musician)");
            musician.FirstName  = "Michael";
            musician.LastName   = "Jackson";
            musician.BirthDate  = new DateTime(1958, 8, 29);
            musician.BirthPlace = "Indiana, USA";

            if (queryMusician.InsertMusician(musician))
            {
                Console.WriteLine("Los datos del músico {0} {1} fueron ingresados con éxito.", musician.FirstName, musician.LastName);
            }
            else
            {
                Console.WriteLine("Error al ingresar los datos: {0}", queryMusician.ErrorMessage);
            }

            /*listOfCountries = queryToCountries.GetCountries();
             *
             * if (listOfCountries == null && queryToCountries.ErrorMessage != string.Empty)
             * {
             *  Console.WriteLine("Error: {0}", queryToCountries.ErrorMessage);
             * }
             * else
             * {
             *  foreach (var item in listOfCountries)
             *  {
             *      Console.WriteLine("País : {0}", item.NameEs);
             *      Console.WriteLine("ISO2 : {0} - ISO3: {1}", item.ISO2, item.ISO3);
             *  }
             * }
             *
             * Console.WriteLine("---------------------------------");
             * Console.WriteLine("Agregue un nuevo país.");
             * Console.Write("Nombre en español: ");
             * country.NameEs = Console.ReadLine();
             *
             * Console.Write("Nombre en inglés: ");
             * country.NameEn = Console.ReadLine();
             *
             * Console.Write("Cód ISO2: ");
             * country.ISO2 = Console.ReadLine();
             *
             * Console.Write("Cód ISO3: ");
             * country.ISO3 = Console.ReadLine();
             *
             * bool record = queryToCountries.InsertCountry(country);
             * if(record)
             *  Console.WriteLine("Los datos del país {0} fueron registrados con éxito.", country.NameEs);
             * else
             *  Console.WriteLine("Error en el registro de datos: {0}", queryToCountries.ErrorMessage);
             */



            //Console.Write("Id: ");
            //// Realizar la consulta a BD
            //int idCountry = Convert.ToInt32(Console.ReadLine());
            //country = queryToCountries.GetCountry(idCountry);

            //if (country != null)
            //{
            //    //mostrar el resultado:
            //    Console.WriteLine("El país tiene los siguientes datos: ");
            //    Console.WriteLine("Nombre: {0} - {1}", country.NameEn, country.ISO3);
            //}
            //else
            //    Console.WriteLine("No hay datos");

            Console.ReadLine();
        }
Ejemplo n.º 13
0
 public CountryController()
 {
     CountryBL = new CountryBL();
 }