예제 #1
0
        public static ChoreModel ConvertFromChore(Chore chore)
        {
            var model = new ChoreModel();

            model.ChoreId     = chore.ChoreId;
            model.Name        = chore.Name;
            model.Difficulty  = chore.Difficulty;
            model.Description = chore.Description;


            if (chore.LastCompleted != null)
            {
                model.LastCompleted     = chore.LastCompleted;
                model.LastCompletedById = chore.LastCompletedBy.ChoreDoerId;
                model.LastCompletedBy   = chore.LastCompletedBy.Name;
            }
            ChoreDoer doer = chore.AssignedTo;

            model.AssignedToId = doer.ChoreDoerId;
            model.AssignedTo   = doer.Name;

            return(model);
        }
예제 #2
0
        //Uses the ChoreId of the model to get the represented data entity Chore.
        public Chore GetRepresentedChore(RotatingChoresContext context)
        {
            Chore chore = context.Chores.SingleOrDefault(c => c.ChoreId == ChoreId);

            return(chore);
        }