/// <summary> /// Deprecated Method for adding a new object to the Projects EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToProjects(Project project) { base.AddObject("Projects", project); }
/// <summary> /// Create a new Project object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="code">Initial value of the Code property.</param> /// <param name="budgetRequestId">Initial value of the BudgetRequestId property.</param> /// <param name="custumerId">Initial value of the CustumerId property.</param> /// <param name="employeeId">Initial value of the EmployeeId property.</param> /// <param name="name">Initial value of the Name property.</param> /// <param name="managementApproval">Initial value of the ManagementApproval property.</param> /// <param name="cxcApproval">Initial value of the CxcApproval property.</param> /// <param name="createDate">Initial value of the CreateDate property.</param> /// <param name="contingenciesRate">Initial value of the ContingenciesRate property.</param> /// <param name="guaranteeRate">Initial value of the GuaranteeRate property.</param> /// <param name="totalUtilityRate">Initial value of the TotalUtilityRate property.</param> /// <param name="discountRate">Initial value of the DiscountRate property.</param> /// <param name="salesTax">Initial value of the SalesTax property.</param> /// <param name="othersRate">Initial value of the OthersRate property.</param> /// <param name="totalMeters">Initial value of the TotalMeters property.</param> /// <param name="comments">Initial value of the Comments property.</param> /// <param name="stateId">Initial value of the StateId property.</param> public static Project CreateProject(global::System.Int32 id, global::System.String code, global::System.Int32 budgetRequestId, global::System.Int32 custumerId, global::System.Int32 employeeId, global::System.String name, global::System.Boolean managementApproval, global::System.Boolean cxcApproval, global::System.DateTime createDate, global::System.Double contingenciesRate, global::System.Double guaranteeRate, global::System.Double totalUtilityRate, global::System.Double discountRate, global::System.Double salesTax, global::System.Double othersRate, global::System.Double totalMeters, global::System.String comments, global::System.Int32 stateId) { Project project = new Project(); project.Id = id; project.Code = code; project.BudgetRequestId = budgetRequestId; project.CustumerId = custumerId; project.EmployeeId = employeeId; project.Name = name; project.ManagementApproval = managementApproval; project.CxcApproval = cxcApproval; project.CreateDate = createDate; project.ContingenciesRate = contingenciesRate; project.GuaranteeRate = guaranteeRate; project.TotalUtilityRate = totalUtilityRate; project.DiscountRate = discountRate; project.SalesTax = salesTax; project.OthersRate = othersRate; project.TotalMeters = totalMeters; project.Comments = comments; project.StateId = stateId; return project; }
internal static ProjectDto Map(Project project) { ProjectDto projectDto = null; if (project != null) { #region Task Charge var taskList = new List<TaskDto>(); foreach (var tmpTask in project.Tasks.ToList()) { var newTask = Map(tmpTask); taskList.Add(newTask); } #endregion #region Customer Charge var customerTypeEntity = project.Customer; Olympus._Enterprise.Detach(customerTypeEntity); var customer = Mapper.Map<CustomerDto>(customerTypeEntity); #endregion #region BudgetRequest Charge var budgetRequest = Mapper.Map<BudgetRequestDto>(project.BudgetRequest); #endregion #region Project State Charge var projectStateTypeEntity = project.State; Olympus._Enterprise.Detach(projectStateTypeEntity); var projectState = Mapper.Map<StateDto>(projectStateTypeEntity); #endregion Olympus._Enterprise.Detach(project); projectDto = Mapper.Map<ProjectDto>(project); projectDto.Customer = customer; projectDto.BudgetRequest = budgetRequest; projectDto.Tasks = taskList; projectDto.State = projectState; } return projectDto; }
/// <summary> /// Delete all the tasks and then put again in the project entity /// </summary> /// <param name="tasks">The collection of tasks that will be added to the project entity</param> /// <param name="projectFound">Project entity that contains the tasks</param> private static void SaveTasks(IEnumerable<TaskDto> tasks, Project projectFound) { if (projectFound.Tasks.Count > 0) { DeleteAllTasks(projectFound); } foreach (var tmpTask in tasks.OrderBy(x => x.RowNumber)) { var taskEntity = Mapper.Map<TaskDto, Task>(tmpTask); Olympus._Enterprise.Tasks.AddObject(taskEntity); } }
/// <summary> /// Delete a project task /// </summary> private static void DeleteAllTasks(Project project) { var delete = project.Tasks.OrderByDescending(x => x.RowNumber).ToList(); foreach (var t in delete) { t.Task1.Clear(); DeleteAllResources(t); Olympus._Enterprise.Tasks.DeleteObject(t); } }
public ProjectResponse SaveProject(ProjectRequest request) { var budgetAdapter = new BudgetAdapter(); var response = new ProjectResponse(); if (request.Project != null) { Project project = null; // Check if Edit or Add if (request.Project.Id > 0) { // Edit project = Olympus._Enterprise.Projects.Where(x => x.Id == request.Project.Id).SingleOrDefault(); Mapper.Map(request.Project, project); if (request.Project.Tasks != null) SaveTasks(request.Project.Tasks, project); } else { // Add if (request.Project.Code != null) { // Check some info from AlienDB project = new Project(); Mapper.Map(request.Project, project); if (request.Project.Tasks != null) SaveTasks(request.Project.Tasks, project); Olympus._Enterprise.Projects.AddObject(project); } } Olympus._Enterprise.SaveChanges(); if (project != null) //Save the Budget in DIALCOM { response.ProjectId = project.Id; var tmpTaskList = SearchTask(project.Id).TaskList; request.ProjectId = project.Id; var tmpProject = GetProject(request).Project; budgetAdapter.SaveBudget(tmpProject, tmpTaskList); } } return response; }