public bool RemoveProject(Project project) { if (projectRepository.Exists(project.ID)) { // concurrency check var storedProj = projectRepository.Get(project.ID); if (storedProj.Updated == project.Updated) projectRepository.Delete(project); else throw new FaultException("Someone changed your object while you edited you copy! Refresh, solve the conflicts at your side and try again!"); return true; } else return false; }
public Project SaveProject(Project project) { if (projectRepository.Exists(project.ID)) { // concurrency check var storedProj = projectRepository.Get(project.ID); if (storedProj.Updated <= project.Updated) projectRepository.Update(project); else throw new FaultException("Someone changed your object while you edited you copy! Refresh, solve the conflicts at your side and try again!"); } else projectRepository.Add(project); return projectRepository.Get(project.ID); // reloading the saved object, there is possibility to exist changed properties after applying business logic }