Пример #1
0
        public async Task <IHttpActionResult> GetNewParameter()
        {
            var unitCode    = _servicePeriod.GetCurrentUnitCode();
            var currentDate = DateTime.Now.Date;
            var result      = new ParameterCustomerCare()
            {
                ToDate   = currentDate,
                FromDate = currentDate,
                MinDate  = currentDate,
                MaxDate  = currentDate,
                UnitCode = unitCode,
            };

            var periodCollection = _servicePeriod.Repository.DbSet.Where(x => x.UnitCode == unitCode && x.TrangThai == (int)ApprovalState.IsComplete);

            if (periodCollection != null && periodCollection.Count() > 0)
            {
                var lastPeriod     = periodCollection.OrderByDescending(x => x.Year).OrderByDescending(x => x.Period).FirstOrDefault();
                var originalPeriod = periodCollection.OrderBy(x => x.Period).FirstOrDefault();
                result.MaxDate = lastPeriod.ToDate;
                result.MinDate = originalPeriod.FromDate;
                result.ToDate  = lastPeriod.ToDate;
                if (lastPeriod.ToDate.AddMonths(-1) >= originalPeriod.FromDate)
                {
                    result.FromDate = lastPeriod.ToDate.AddMonths(-1);
                }
                else
                {
                    result.FromDate = originalPeriod.FromDate;
                }
            }

            return(Ok(result));
        }
Пример #2
0
        public async Task <IHttpActionResult> PostCustomerLevelUp(ParameterCustomerCare para)
        {
            var result = new TransferObj <List <MdCustomer> >();

            try
            {
                result.Data   = _service.CustomerLevelUpCollection(para);
                result.Status = true;
                return(Ok(result));
            }
            catch (Exception e)
            {
                return(InternalServerError());
            }
        }
Пример #3
0
        public async Task <IHttpActionResult> ReportCustomerLevelUp(ParameterCustomerCare para)
        {
            var result = new TransferObj <ReportLoyalCustomer>();

            try
            {
                var reporter = new ReportLoyalCustomer();
                var data     = new List <MdCustomer>();
                reporter.UnitCode = _servicePeriod.GetCurrentUnitCode();
                var unitCode = _servicePeriod.GetCurrentUnitCode();
                reporter.FromDate    = para.FromDate;
                reporter.ToDate      = para.ToDate;
                reporter.CreateDate  = DateTime.Now;
                reporter.TenDonVi    = CurrentSetting.GetUnitName(unitCode);
                reporter.DiaChiDonVi = CurrentSetting.GetUnitAddress(unitCode);
                //GetNhanVien
                if (HttpContext.Current != null && HttpContext.Current.User is ClaimsPrincipal)
                {
                    var currentUser = (HttpContext.Current.User as ClaimsPrincipal);
                    var name        = currentUser.Identity.Name;
                    var nhanVien    = _service.UnitOfWork.Repository <AU_NGUOIDUNG>().DbSet.Where(x => x.Username == name).FirstOrDefault();
                    if (nhanVien != null)
                    {
                        reporter.Username = nhanVien.TenNhanVien;
                    }
                    else
                    {
                        reporter.Username = "******";
                    }
                }
                reporter.Data  = _service.ReportCustomerLevelUp(para);
                result.Data    = reporter;
                result.Status  = true;
                result.Message = "Xuất báo cáo thành công";
                return(Ok(result));
            }
            catch (Exception e)
            {
                return(InternalServerError());
            }
        }