Пример #1
0
        public List <ContactOutputDto> ListOfContacts()
        {
            var listOfContacts = new List <ContactOutputDto>();

            using (var context = new AppicoContext())
            {
                var contactRepository = new ContactRepository().InitRepository(context);
                var dealerRepository  = new DealerRepository().InitRepository(context);
                var modelRepository   = new ModelRepository().InitRepository(context);
                listOfContacts = (from contactData in contactRepository.AllContacts()
                                  join dealerData in dealerRepository.AllDealers() on
                                  contactData.dealer equals dealerData.guid
                                  join modelData in modelRepository.AllModels() on
                                  contactData.model equals modelData.guid
                                  select new ContactOutputDto()
                {
                    Name = contactData.name,
                    EMail = contactData.email,
                    DealerName = dealerData.name,
                    ModelMake = modelData.make,
                    ModelName = modelData.model,
                    ModelType = modelData.type,
                    Message = contactData.message != null ? contactData.message: string.Empty,
                    CreatedDate = contactData.created.ToShortDateString()
                }).ToList();
            }
            return(listOfContacts);
        }
Пример #2
0
        public virtual Task <IAppDealer> Create()
        {
            var crmService = StartupHelper.CreateCrmService();
            IDealerRepository dealerrepository = new DealerRepository();
            IDealerService    dealerservice    = new DealerService(crmService, dealerrepository);
            IAppDealer        app = new AppDealer(dealerservice);

            return(Task.FromResult(app));;
        }
Пример #3
0
        public List <DealerDto> ListOfDealer()
        {
            var listOfDealers = new List <DealerDto>();

            using (var context = new AppicoContext())
            {
                var repository = new DealerRepository();
                listOfDealers = repository.InitRepository(context)
                                .AllDealers()
                                .Select(d => new DealerDto()
                {
                    guid = d.guid,
                    Name = d.name
                }).ToList();
            }
            return(listOfDealers);
        }
Пример #4
0
        public ActionResult Index(string id)
        {
            DealerRepository dRepository = new DealerRepository();

            try
            {
                var dInfo = dRepository.GetDealer(id);

                ViewBag.FullSiteURL = FullSiteURL();

                return(View(dInfo));
            }
            catch
            {
            }

            return(Redirect(FullSiteURL() + "/404-page/"));
        }
        public IList<SalesReturnListViewModel> Get(int companyid, DateTime StartDate, DateTime EndDate)
        {
            IList<SalesReturnListViewModel> returnList = new List<SalesReturnListViewModel>();
            IList<ERPOptima.Model.Sales.SlsSalesReturn> list = new List<ERPOptima.Model.Sales.SlsSalesReturn>();
            //DataTable dt = new DataTable();

            //SqlParameter[] paramsToStore = new SqlParameter[2];
            //paramsToStore[0] = new SqlParameter("@StartDate", StartDate);
            //paramsToStore[1] = new SqlParameter("@EndDate", EndDate);

            try
            {
                // dt = _SalesReturnRepository.GetFromStoredProcedure(SPList.Report.RptSalesReturnList, paramsToStore);
                list = _SalesReturnRepository.Get(companyid, StartDate, EndDate);
                if (list != null && list.Count > 0)
                {
                    foreach (ERPOptima.Model.Sales.SlsSalesReturn itm in list)
                    {
                        var dbfactory = new DatabaseFactory();
                        SalesReturnListViewModel tmp = new SalesReturnListViewModel();
                        tmp.Id = itm.Id;
                        tmp.RefNo = itm.RefNo;
                        tmp.CreatedDate = itm.CreatedDate;
                        switch (itm.PartyType)
                        {
                            case 1:
                                ERPOptima.Data.Sales.Repository.DistributorRepository rposDistrbutor = new DistributorRepository(dbfactory);
                                tmp.Party = rposDistrbutor.GetById((int)itm.Party).Name;
                                break;
                            case 2:
                                ERPOptima.Data.Sales.Repository.RetailerRepository rposRetailer = new RetailerRepository(dbfactory);
                                tmp.Party = rposRetailer.GetById((int)itm.Party).Name;
                                break;
                            case 3:
                                ERPOptima.Data.Sales.Repository.DealerRepository rposDealer = new DealerRepository(dbfactory);
                                tmp.Party = rposDealer.GetById((int)itm.Party).Name;
                                break;
                            case 4:
                                ERPOptima.Data.Sales.Repository.CorporateClientRepository rposCorporateClient = new CorporateClientRepository(dbfactory);
                                tmp.Party = rposCorporateClient.GetById((int)itm.Party).Name;
                                break;
                        }
                        returnList.Add(tmp);
                    }
                }

            }
            catch (Exception)
            {
            }
            //if (dt != null && dt.Rows.Count > 0)
            //{
            //    list = dt.DataTableToList<SalesReturnListViewModel>();
            //}
            return returnList;
        }
        /// <summary>
        /// From,To,netsales for General Rate. 
        /// </summary>
        /// <param name="From">From</param>
        /// <param name="To">To</param>
        /// <param name="netsales">netsales</param>
        /// <param name="PartyType">PartyType</param>
        /// <param name="Party">Party</param>
        /// <returns></returns>
        public decimal GetCommissionRate(DateTime From, DateTime To, decimal netsales, int PartyType, int Party)
        {
            decimal commission = 0;

            if (PartyType == 1)
            {
                //set commission from Distributor's own account
                var distributors = new DistributorRepository(new DatabaseFactory()).GetAll();
                var distributor = distributors.Where(i => i.Id == Party).FirstOrDefault();
                if (distributor != null && distributor.Id > 0 && distributor.RateOfCommission != null)
                {
                    commission = (decimal)distributor.RateOfCommission;
                }
            }
            else if (PartyType == 3)
            {
                //set commission from Dealer's own account
                var dealers = new DealerRepository(new DatabaseFactory()).GetAll();
                var dealer = dealers.Where(i => i.Id == Party).FirstOrDefault();
                if (dealer != null && dealer.Id > 0 && dealer.RateOfCommission != null)
                {
                    commission = (decimal)dealer.RateOfCommission;
                }
            }

            if (commission <= 0)
            {
                //Get recent package settings
                var list = _CommissionPackageRepository.GetAll();
                if (list != null && list.Count() > 0)
                {
                    list = list.Where(i => From.Year >= i.Year && To.Year <= i.Year &&
                        From.Month >= i.Month && To.Month <= i.Month &&
                        netsales >= i.LowerTarget && netsales <= i.UpperTarget).ToList();

                    //22-04-2015: Here if multiple package information found, latest package will be set as commission rate.
                    if(list != null && list.Count() > 0)
                    {
                        var recent = list.OrderByDescending(i => i.Year).OrderByDescending(i => i.Month).ToList().FirstOrDefault();
                        commission = recent.Commission;
                    }
                }
            }

            return commission;
        }
Пример #7
0
 public DealerController(DealerRepository dealerRepository)
 {
     _dealerRepository = dealerRepository;
 }