示例#1
0
        public TaskItemView Get(Guid id)
        {
            var task = _taskRepository.GetTaskById(id);

            return(new TaskItemView()
            {
                Id = task.Id,
                Name = task.Name,
                PercentComplete = task.PercentComplete,
                Status = task.Status,
                StatusText = EnumDescription.GetDescription(task.Status)
            });
        }
 public void TestGetDescriptionForEnumWithDescriptions()
 {
     using (new CultureScope(CultureInfo.InvariantCulture, CultureInfo.InvariantCulture))
     {
         // try twice to test caching
         for (int i = 0; i < 2; ++i)
         {
             Assert.That(EnumDescription.GetDescription(EnumWithDescription.Value1), Is.EqualTo("Value I"));
             Assert.That(EnumDescription.GetDescription(EnumWithDescription.Value2), Is.EqualTo("Value II"));
             Assert.That(EnumDescription.GetDescription(EnumWithDescription.ValueWithoutDescription), Is.EqualTo("ValueWithoutDescription"));
             Assert.That(EnumDescription.GetDescription((EnumWithDescription)100), Is.EqualTo("100"));
         }
     }
 }
        public void TestGetDescriptionForEnumFromResource()
        {
            using (new CultureScope(CultureInfo.InvariantCulture, CultureInfo.InvariantCulture))
            {
                Assert.That(EnumDescription.GetDescription(EnumWithResources.Value1), Is.EqualTo("Value 1"));
                Assert.That(EnumDescription.GetDescription(EnumWithResources.Value2), Is.EqualTo("Value 2"));
                Assert.That(EnumDescription.GetDescription(EnumWithResources.ValueWithoutResource), Is.EqualTo("ValueWithoutResource"));
                Assert.That(EnumDescription.GetDescription((EnumWithResources)100), Is.EqualTo("100"));

                CultureInfo culture = new CultureInfo("de-AT");
                Assert.That(EnumDescription.GetDescription(EnumWithResources.Value1, culture), Is.EqualTo("Wert 1"));
                Assert.That(EnumDescription.GetDescription(EnumWithResources.Value2, culture), Is.EqualTo("Wert 2"));
                Assert.That(EnumDescription.GetDescription(EnumWithResources.ValueWithoutResource, culture), Is.EqualTo("ValueWithoutResource"));
                Assert.That(EnumDescription.GetDescription((EnumWithResources)100, culture), Is.EqualTo("100"));
            }
        }
示例#4
0
        public IEnumerable <TaskItemView> Get()
        {
            List <TaskItemView> tasksView = new List <TaskItemView>();
            var tasks = _taskRepository.Get();

            foreach (var task in tasks)
            {
                tasksView.Add(new TaskItemView()
                {
                    Id              = task.Id,
                    Name            = task.Name,
                    PercentComplete = task.PercentComplete,
                    Status          = task.Status,
                    StatusText      = EnumDescription.GetDescription(task.Status)
                });
            }
            return(tasksView);
        }
示例#5
0
        /// <summary>
        /// 根据卡片收费记录生成停车收费小票
        /// </summary>
        /// <param name="cardPayment"></param>
        /// <returns></returns>
        public static ParkBillInfo CreateParkBill(CardPaymentRecord cardPayment)
        {
            ParkBillInfo bill = new ParkBillInfo();

            bill.CardID         = cardPayment.CardID;
            bill.Accounts       = cardPayment.Accounts;
            bill.CarType        = EnumDescription.GetDescription(cardPayment.CarType);
            bill.ChargeDateTime = cardPayment.ChargeDateTime;
            bill.CompanyName    = GeneralSetting.Current.CompanyName;
            if (cardPayment.EnterDateTime != null)
            {
                bill.EnterDateTime = cardPayment.EnterDateTime.Value;
            }
            bill.HavePaid     = cardPayment.HavePaid;
            bill.LastAccounts = cardPayment.LastAccounts;
            bill.Operator     = OperatorInfo.CurrentOperator.OperatorName;
            bill.OwnerName    = cardPayment.OwnerName;
            bill.Paid         = cardPayment.Paid;
            bill.TariffType   = EnumDescription.GetDescription(cardPayment.TariffType);
            return(bill);
        }
示例#6
0
        public async Task <TaskItemView> CreateTask(TaskItemCreateDto taskItem)
        {
            var taskId = _taskRepository.Add(new TaskItemModel()
            {
                Name            = taskItem.TaskName.Trim(),
                PercentComplete = 0,
                Status          = StatusTask.WaitingToStart
            });
            var task = _taskRepository.GetTaskById(taskId);
            await _notifyService.SendToClient(taskItem.NotifyConnectionId, $"Вы поставили задачу '{taskItem.TaskName.Trim()}' в очередь");

            await _notifyService.SendExceptClient(taskItem.NotifyConnectionId, $"Добавлена новая задача '{taskItem.TaskName.Trim()}'");

            return(new TaskItemView()
            {
                Id = task.Id,
                Name = task.Name,
                PercentComplete = task.PercentComplete,
                Status = task.Status,
                StatusText = EnumDescription.GetDescription(task.Status)
            });
        }
示例#7
0
        public List <HistoryProposalDTO> Get(int idProposal)
        {
            var list = context.Historic
                       .Where(x => x.IdProposal == idProposal)
                       .GroupJoin(
                context.Users,
                historic => historic.IdUser,
                users => users.Id,
                (historic, users) => new { historic, users })
                       .AsEnumerable()
                       .Select(item => new HistoryProposalDTO {
                Action            = (int)item.historic.Action,
                ActionDate        = item.historic.ActionDate,
                ActionDescription = EnumDescription.GetDescription(item.historic.Action),
                Id         = item.historic.Id,
                IdProposal = item.historic.IdProposal,
                IdUser     = item.historic.IdUser,
                UserName   = item.users.Where(x => x.Id == item.historic.IdUser).FirstOrDefault() == null ? "Sistema" : item.users.Where(x => x.Id == item.historic.IdUser).FirstOrDefault().Name
            })
                       .ToList();

            return(list);
        }
示例#8
0
        public List <ProposalDTO> Get()
        {
            var list = context.Proposals
                       .Join(
                context.Categories,
                proposal => proposal.IdCategory,
                category => category.Id,
                (proposal, category) => new { proposal, category }
                )
                       .Join(
                context.Suppliers,
                join => join.proposal.IdSupplier,
                supplier => supplier.Id,
                (join, supplier) => new { join, supplier })
                       .AsEnumerable()
                       .Select(item => new ProposalDTO
            {
                CategoryName         = item.join.category.Name,
                CreationDate         = item.join.proposal.CreationDate,
                ExpirationDate       = item.join.proposal.ExpirationDate,
                Expireded            = DateTime.Now > item.join.proposal.ExpirationDate,
                Description          = item.join.proposal.Description,
                Id                   = item.join.proposal.Id,
                IdCategory           = item.join.proposal.IdCategory,
                IdSupplier           = item.join.proposal.IdSupplier,
                Name                 = item.join.proposal.Name,
                NameFile             = item.join.proposal.NameFile,
                Status               = (int)item.join.proposal.Status,
                StatusDescription    = EnumDescription.GetDescription(item.join.proposal.Status),
                StatusNow            = (int)item.join.proposal.StatusNow,
                StatusNowDescription = EnumDescription.GetDescription(item.join.proposal.StatusNow),
                SupplierName         = item.supplier.Name,
                Value                = item.join.proposal.Value
            }).ToList();

            return(list);
        }