public bool AddPlanToGroup(int planId, int groupId) { using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required)) { Plan plan = _planRepository.Get(_ => _.Id == planId, _ => _.Notes, _ => _.PlanLocations); if (plan != null) { Plan clone = Clone.CloneObject(plan); if (clone != null) { clone.IsPublic = false;//default when clone clone.GroupId = groupId; clone.MemberId = null; _planRepository.Create(clone); _unitOfWork.SaveChanges(); scope.Complete(); return(true); }//clone success } return(false); } }
public Plan PublicPlan(int planId) { var plan = Find(planId, _ => _.Notes, _ => _.PlanLocations); var cloner = Clone.CloneObject(plan); cloner.MemberId = null; cloner.GroupId = null; cloner.IsPublic = true; foreach (var item in cloner.Notes) { item.Done = false; } foreach (var item in cloner.PlanLocations) { item.Done = false; } Create(cloner); return(cloner); }
public Plan ClonePlan(int planId) { var plan = Find(planId, _ => _.Notes, _ => _.PlanLocations); return(Clone.CloneObject(plan)); }