Example #1
0
        public async Task <QueueResult> Handle(string data)
        {
            QueueResult result = new QueueResult(Data.Enums.ProcessType.DeleteCountry);

            if (string.IsNullOrEmpty(data))
            {
                result.ExceptionCode = ExceptionCode.MissingQueueData;
            }
            CountryQueue countryQueue = null;

            try
            {
                countryQueue = JsonConvert.DeserializeObject <CountryQueue>(data);
                CountryLogic countryLogic = new CountryLogic(this.db, result.AdditionalData, this.loggerFactory);
                await countryLogic.DeleteCountry(countryQueue);

                result.AdditionalData.Add("countryId", countryQueue.Id.ToString());
                result.AdditionalData.Add("countryName", countryQueue.Name);

                result.Status = Status.Success;
            }
            catch (Exception ex)
            {
                HandleException(ex, result, countryQueue);
            }
            return(result);
        }
Example #2
0
        public void SelectAllDataTest()
        {
            Mock <IRepository <country> > mock = new Mock <IRepository <country> >();
            country c = new country
            {
                id         = 1,
                population = 100,
            };

            mock.Setup(m => m.GetAll()).Returns(new List <country>()
            {
                new country {
                    id = 1, population = 100
                },
                new country {
                    id = 2, population = 200
                },
                new country {
                    id = 3, population = 300
                },
            }.AsQueryable());

            ILogic <country> il = new CountryLogic(mock.Object);

            Assert.That(il.GetAll().Sum(x => x.population) == 600);
        }
Example #3
0
        public void ModifyCountryTest([Values(100)] int value)
        {
            Mock <IRepository <country> > mock = new Mock <IRepository <country> >(MockBehavior.Loose);

            mock.Setup(m => m.GetAll()).Returns(new List <country>()
            {
                new country {
                    id = 1, population = 2343231
                },
                new country {
                    id = 2, population = 89495665
                },
                new country {
                    id = 3, population = 56195615
                },
                new country {
                    id = 4, population = 9619819
                },
                new country {
                    id = 5, population = 56115656
                },
            }.AsQueryable());

            ILogic <country> il = new CountryLogic(mock.Object);

            il.Modify(1, value);
            mock.Verify(m => m.Modify(1, value));
        }
Example #4
0
        public List <CountryBE> GetCountryAll()
        {
            List <CountryBE> ltscouall = new List <CountryBE>();
            CountryLogic     CL        = new CountryLogic();

            ltscouall = CL.GetCountryAll();
            return(ltscouall);
        }
Example #5
0
        // GET: Countries
        public virtual ActionResult Index()
        {
            var result = CountryLogic.GetAll();

            var viewModel = new IndexViewModel();

            viewModel.Items = Mapper.Map <IEnumerable <IndexItemViewModel> >(result.Value);

            return(View(viewModel));
        }
Example #6
0
        public virtual ActionResult Details(Guid id)
        {
            var result = CountryLogic.GetById(id);

            if (result.Success == false)
            {
                return(HttpNotFound());
            }

            var viewModel = Mapper.Map <CountryViewModel>(result.Value);

            return(View(viewModel));
        }
Example #7
0
 public LookupsController()
 {
     _unitsLogic         = new UnitsLogic();
     _deliveryTermsLogic = new DeliveryTermsLogic();
     _paymentTermsLogic  = new PaymentTermsLogic();
     _countryLogic       = new CountryLogic();
     _projectLogic       = new ProjectLogic();
     _materialLogic      = new MaterialLogic();
     _productLogic       = new ProductLogic();
     _itemSizeLogic      = new ItemSizeLogic();
     _makeLogic          = new MakeLogic();
     _gradeLogic         = new GradeLogic();
     _accountLogic       = new AccountTypeLogic();
     _paymentMethodLogic = new PaymentMethodLogic();
 }
Example #8
0
 private void DeleteCountryById(int id)
 {
     try
     {
         using (var countries = new CountryLogic())
         {
             var opSuccessful = countries.DeleteCountryById(id);
         }
     }
     catch (Exception ex)
     {
         //Log exception error
         _loggingHandler.LogEntry(ExceptionHandler.GetExceptionMessageFormatted(ex), true);
     }
 }
Example #9
0
 private Country SelectCountryById(int id)
 {
     try
     {
         using (var country = new CountryLogic())
         {
             return(country.SelectCountryById(id));
         }
     }
     catch (Exception ex)
     {
         //Log exception error
         _loggingHandler.LogEntry(ExceptionHandler.GetExceptionMessageFormatted(ex), true);
     }
     return(null);
 }
Example #10
0
 private List <Country> ListAllCountries()
 {
     try
     {
         using (var employees = new CountryLogic())
         {
             return(employees.SelectAllCuntries());
         }
     }
     catch (Exception ex)
     {
         //Log exception error
         _loggingHandler.LogEntry(ExceptionHandler.GetExceptionMessageFormatted(ex), true);
     }
     return(null);
 }
Example #11
0
 private void UpdateCountry(int id, string name, string shortName)
 {
     try
     {
         using (var countries = new CountryLogic())
         {
             var entity = new Country();
             entity.CountryID        = id;
             entity.nameCountry      = name;
             entity.shortNameCountry = shortName;
             var opSuccessful = countries.UpdateCountry(entity);
         }
     }
     catch (Exception ex)
     {
         //Log exception error
         _loggingHandler.LogEntry(ExceptionHandler.GetExceptionMessageFormatted(ex), true);
     }
 }
Example #12
0
        public virtual ActionResult Create(CountryViewModel viewModel)
        {
            if (ModelState.IsValid == false)
            {
                return(View(viewModel));
            }

            var country = Mapper.Map <Country>(viewModel);

            var result = CountryLogic.Add(country);

            if (result.Success == false)
            {
                result.AddErrorToModelState(ModelState);
                return(View(viewModel));
            }

            return(RedirectToAction(MVC.Countries.Index()));
        }
Example #13
0
        private static void Main(string[] args)
        {
            using (var db = new BloggingContext())
            {
                BlogLogic newBlog = new BlogLogic();
                //newBlog.createAndSaveBlock();
                //displaying all the blogs
                //newBlog.DisplayBlogs();

                OrganizationLogic newOrg = new OrganizationLogic();
                //newOrg.NewUserForOrg();
                //newOrg.PrintOrganizations();
                //newOrg.PrintOrganizaionsAndTheirUsers();
                //newOrg.MakeOrganization();

                CountryLogic newCountryLogic = new CountryLogic();
                //newCountryLogic.PrintCountriesAndOrgs();

                Console.WriteLine("Press any key to exit...");
                Console.ReadKey();
            }
        }