Exemplo n.º 1
0
        public Chore UpdateChore([FromBody] Chore chore, DayOfWeek?choreEditedDay = null)
        {
            if (chore == null)
            {
                throw new InvalidParameterException("Invalid parameters!");
            }

            chore = _choreService.Update(chore, choreEditedDay);

            if (chore.FrequencyType != FrequencyType.Once)
            {
                _recurringChoreService.UpdateRecurringChore(chore.Id, chore.FrequencyType, _currentUserService.FamilyID, choreEditedDay);
            }

            return(chore);
        }
        /// <summary>
        /// Save chore workflow
        /// </summary>
        /// <param name="choreWorkflow">Chore workflow</param>
        public void SaveChoreWorkflow(ChoreWorkflow choreWorkflow)
        {
            choreWorkflow.WorkflowStatus = WorkflowStatus.Completed;
            Repository.Update(choreWorkflow);

            // Add new chore from chore work flow via sms
            var chore = new Chore
            {
                ChoreStatus    = ChoreStatus.Active,
                CreatedTime    = DateTime.UtcNow,
                DueDate        = choreWorkflow.DueDate,
                FamilyMemberID = choreWorkflow.ChildMemberID,
                FrequencyRange = choreWorkflow.FrequencyRange,
                FrequencyType  = choreWorkflow.FrequencyType.Value,
                Name           = choreWorkflow.Name.FirstCharToUpper(),
                Value          = choreWorkflow.Value.Value
            };

            chore = _choreService.Add(chore, choreWorkflow.ChildMember.User.FamilyID, DateTime.Now.DayOfWeek);
            if (chore.FrequencyType != FrequencyType.Once)
            {
                _recurringChoreService.UpdateRecurringChore(chore.Id, chore.FrequencyType, choreWorkflow.ChildMember.User.FamilyID, DateTime.Now.DayOfWeek);
            }
        }