Exemple #1
0
        public override void AssignFrom(PartakerEntity entity)
        {
            base.AssignFrom(entity);

            this.Task = entity.Task.ToViewModel();
            this.Staff = entity.Staff.ToViewModel();
        }
 private static PartakerNotExistsResult Check(PartakerEntity partaker, string message)
 {
     if (partaker != null)
     {
         return new PartakerNotExistsResult(false, message, partaker);
     }
     return new PartakerNotExistsResult(true, null, null);
 }
Exemple #3
0
        public virtual void AssignFrom(PartakerEntity entity)
        {
            if (entity == null) throw new ArgumentNullException(nameof(entity));

            this.Id = entity.Id;
            this.TaskId = entity.Task.Id;
            this.StaffId = entity.Staff.Id;
            this.Kind = entity.Kind;
        }
Exemple #4
0
        public  virtual void AssignFrom(PartakerEntity entity, bool isShowhighOnly = false, bool isShowLow = true)
        {

            if (entity == null) throw new ArgumentNullException(nameof(entity)); 


            var propertiesDic = new Dictionary<string, Func<PartakerEntity, dynamic>>
            {
                ["Kind"] = (t) => t.Kind,
                ["Id"] = (t) => t.Id,
                ["Task"] = (t) => t.Task.ToViewModel(),
                ["Staff"] = (t) => t.Staff.ToViewModel(isShowhighOnly,isShowLow),
                ["Kind"] = (t) => t.Kind,
                ["CreatedAt"] = (t) => t.CreatedAt
            };

            NecessityAttributeUitl<PartakerViewModel, PartakerEntity>.SetVuleByNecssityAttribute(this, entity, propertiesDic, isShowhighOnly,
                isShowLow);
        } 
 public PartakerNotExistsResult(bool isSucceed, String message, PartakerEntity partaker)
     : base(isSucceed, message)
 {
     this.Partaker = partaker;
 }
Exemple #6
0
        public override void Seed()
        {
            var random = new Random();
            const int lineWidth = 80;

            var newAccounts = new List<AccountEntity>();
            for (int accountIndex = 1; accountIndex <= NumberOfAccounts; accountIndex++)
            {
                Console.Write($"\rGenerating {NumberOfAccounts} Accounts .... {accountIndex}");

                var account = CreateNewAccount(accountIndex);

                newAccounts.Add(account);
                this.Accounts.Add(account);
                this.DbContext.SaveChanges();
            }
            Console.WriteLine($"\rGenerating {NumberOfAccounts} Accounts .... OK".PadRight(lineWidth));

            var newOrgs = new List<OrgEntity>();
            for (int orgIndex = 1; orgIndex <= NumberOfOrgs; orgIndex++)
            {
                Console.Write($"\rGenerating {NumberOfOrgs} Orgs .... {orgIndex}");

                var org = CreateNewOrg(orgIndex);

                newOrgs.Add(org);
                this.Orgs.Add(org);
                this.DbContext.SaveChanges();
            }
            Console.WriteLine($"\rGenerating {NumberOfOrgs} Orgs .... OK".PadRight(lineWidth));

            var numberOfStaffs = NumberOfAccounts;
            var newStaffs = new List<StaffEntity>();
            for (var staffIndex = 1; staffIndex <= numberOfStaffs; staffIndex ++)
            {
                Console.Write($"\rGenerating {numberOfStaffs} Staffs .... {staffIndex}");

                var account = newAccounts[staffIndex - 1];
                var org = newOrgs[random.Next(newOrgs.Count - 1)];
                var staff = CreateNewStaff(staffIndex, org, account);

                newStaffs.Add(staff);
                this.Staffs.Add(staff);
                this.DbContext.SaveChanges();
            }
            Console.WriteLine($"\rGenerating {numberOfStaffs} Staffs .... OK".PadRight(lineWidth));

            var newTasks = new List<TaskEntity>();
            for (int taskIndex = 1; taskIndex <= NumberOfTasks; taskIndex++)
            {
                Console.Write($"\rGenerating {NumberOfTasks} Tasks .... {taskIndex}");

                var staff = newStaffs[random.Next(newStaffs.Count - 1)];
                var task = CreateNewTask(taskIndex, staff);

                newTasks.Add(task);
                this.Tasks.Add(task);
                this.DbContext.SaveChanges();

                //增加参与者
                var leader = new PartakerEntity();
                leader.Id = Guid.NewGuid();
                leader.Task = task;
                leader.Kind = PartakerKinds.Leader;
                leader.Staff = task.Creator;
                this.Partakers.Add(leader);

                this.DbContext.SaveChanges();
            }
            Console.WriteLine($"\rGenerating {NumberOfTasks} Tasks .... OK".PadRight(lineWidth));

            for (int kindIndex = 1; kindIndex <= IncentiveKind.Count(); kindIndex++)
            {
                Console.Write($"\rGenerating {IncentiveKind.Count()} IncentiveKind .... {kindIndex}");
                var  item= IncentiveKind.Skip(kindIndex - 1).First();
                var kind=CreateNewIncentiveKind(kindIndex, item.Key, item.Value);
                this.IncentiveKinds.Add(kind);
                this.DbContext.SaveChanges(); 
            }
            Console.WriteLine($"\rGenerating {IncentiveKind.Count()} IncentiveKind .... OK".PadRight(lineWidth));
        }