public ManagerResultViewModel createRelationShip(int MerchantId, int OperatorId)
        {
            var _mm       = new MerchantManager();
            var _om       = new OperatorManager();
            var _merchat  = _mm.GetMerchant(MerchantId); //gets merchant object
            var _operator = _om.GetOperator(OperatorId); //gets operator object
            var _mrvm     = new ManagerResultViewModel();

            _mrvm.country       = _operator.country + " and " + _merchat.country + " respectively";
            _mrvm.name          = _operator.name + " and " + _merchat.name;
            _mrvm.Entity        = "Operator and Merchant";
            _mrvm.OperationType = "creation of the relationship";
            if (_merchat != null && _operator != null)
            {
                var channel = from sc in _db.saleChannel
                              where sc.merchantId == MerchantId && sc.operatorId == OperatorId
                              select sc;
                if (!channel.Any())
                {
                    _db.saleChannel.Add(new SaleChannel {
                        merchantId = MerchantId, operatorId = OperatorId
                    });
                    _mrvm.isSuccessful = true;
                    _db.SaveChanges();
                    return(_mrvm);
                }
            }
            _mrvm.isSuccessful = false;
            _mrvm.reason       = "the relationship already exists or operator and/or merchant don't exist";
            return(_mrvm);
        }
        public IEnumerable <SelectListItem> GetMerchantsList()
        {
            var _mm        = new MerchantManager();
            var elements   = _mm.readDb();
            var selectList = new List <SelectListItem>();

            foreach (var element in elements)
            {
                selectList.Add(new SelectListItem
                {
                    Value = element.Id.ToString(),
                    Text  = element.name
                });
            }
            return(selectList);
        }
        public IEnumerable <SelectListItem> GetOperatorsList(int id)
        {
            var selectList = new List <SelectListItem>();
            var _charters  = readDb();
            var _om        = new OperatorManager();
            var _operators = _om.readDb();
            var _mm        = new MerchantManager();
            var _merchants = _mm.readDb();

            foreach (var item in _operators)
            {
                if (_charters.Find(m => (m.operatorId == item.Id) && (m.merchantId == id)) == null)
                {
                    selectList.Add(new SelectListItem
                    {
                        Value = item.Id.ToString(),
                        Text  = item.name
                    });
                }
            }
            return(selectList);
        }