public RemoveProgramInToDosDataResponse RemoveProgramInToDos(RemoveProgramInToDosDataRequest request) { RemoveProgramInToDosDataResponse response = new RemoveProgramInToDosDataResponse(); try { ISchedulingRepository repo = Factory.GetRepository(request, RepositoryType.ToDo); if (request.ProgramId != null) { List <ToDoData> todos = repo.FindToDosWithAProgramId(request.ProgramId) as List <ToDoData>; if (todos != null && todos.Count > 0) { todos.ForEach(u => { request.ToDoId = u.Id; if (u.ProgramIds != null && u.ProgramIds.Remove(request.ProgramId)) { repo.RemoveProgram(request, u.ProgramIds); } }); } } return(response); } catch (Exception ex) { throw ex; } }
public void RemoveProgramInToDos_Test() { RemoveProgramInToDosDataRequest request = new RemoveProgramInToDosDataRequest { Context = context, ContractNumber = contractNumber, ProgramId = "5400b12bd6a4850940b9f245", UserId = userId, Version = version }; ISchedulingDataManager cm = new SchedulingDataManager { Factory = new SchedulingRepositoryFactory() }; RemoveProgramInToDosDataResponse response = cm.RemoveProgramInToDos(request); Assert.IsNotNull(response); }
public void RemoveProgramInToDos_Test() { RemoveProgramInToDosDataRequest request = new RemoveProgramInToDosDataRequest { Context = context, ContractNumber = contractNumber, ProgramId = "535ad70ad2d8e912e857525c", UserId = userId, Version = version }; ISchedulingDataManager cm = new StubToDoDataManager { Factory = new StubSchedulingRepositoryFactory() }; RemoveProgramInToDosDataResponse response = cm.RemoveProgramInToDos(request); Assert.IsNotNull(response); }
public RemoveProgramInToDosDataResponse Put(RemoveProgramInToDosDataRequest request) { RemoveProgramInToDosDataResponse response = new RemoveProgramInToDosDataResponse(); try { if (string.IsNullOrEmpty(request.UserId)) { throw new UnauthorizedAccessException("SchedulingDD:RemoveProgramInToDos()::Unauthorized Access"); } response = Manager.RemoveProgramInToDos(request); response.Version = request.Version; } catch (Exception ex) { CommonFormatter.FormatExceptionResponse(response, base.Response, ex); string aseProcessID = ConfigurationManager.AppSettings.Get("ASEProcessID") ?? "0"; Common.Helper.LogException(int.Parse(aseProcessID), ex); } return(response); }