public ActionResult CreateWBSTypeFromTemplate(string name, string description,int id) { try { var newtype = new WbsType { Name = name, Description = description }; _wbsTaskRepository.Add(newtype); UnitOfWork.Commit(); var templatewbs = _wbsTaskRepository.Find(id); newtype.TaskNodes = new Collection<TaskNode>(); var tasks = templatewbs.TaskNodes.ToList(); tasks.ForEach(x=> newtype.TaskNodes.Add(new TaskNode{WbsTypeId = newtype.WbsTypeId,CountWorkDay = x.CountWorkDay,DateCreated = DateTime.Now, DayToCost = x.DayToCost,TaskName = x.TaskName,WBSCode = x.WBSCode, StageValue = x.StageValue,StageEnd = x.StageEnd,NodeFlag = x.NodeFlag, RoleId = x.RoleId })); UnitOfWork.Commit(); return Json(new JsonResponse { Success = true, Result = newtype }); } catch (Exception ex) { return Json(new JsonResponse { Success = false, Message = ex.Message }); } }
public ActionResult CreateWBSType(string name, string description) { try { var newtype = new WbsType {Name = name, Description = description}; _wbsTaskRepository.Add(newtype); UnitOfWork.Commit(); return Json(new JsonResponse { Success = true, Result = newtype }); } catch (Exception ex) { return Json(new JsonResponse { Success = false, Message = ex.Message }); } }