/// <summary> /// 获得分页列表,无论是否是缓存实体都从数据库直接拿取数据 /// </summary> /// <param name="pPageIndex">页数</param> /// <param name="pPageSize">每页列表</param> /// <param name="pOrderBy">排序</param> /// <param name="pSortExpression">排序字段</param> /// <param name="pRecordCount">列表行数</param> /// <returns>数据分页</returns> public static List <ProjectCreateInfo> GetPagedList(int pPageIndex, int pPageSize, SortDirection pOrderBy, string pSortExpression, out int pRecordCount) { if (pPageIndex <= 1) { pPageIndex = 1; } List <ProjectCreateInfo> list = new List <ProjectCreateInfo>(); Query q = ProjectCreate.CreateQuery(); q.PageIndex = pPageIndex; q.PageSize = pPageSize; q.ORDER_BY(pSortExpression, pOrderBy.ToString()); ProjectCreateCollection collection = new ProjectCreateCollection(); collection.LoadAndCloseReader(q.ExecuteReader()); foreach (ProjectCreate projectCreate in collection) { ProjectCreateInfo projectCreateInfo = new ProjectCreateInfo(); LoadFromDAL(projectCreateInfo, projectCreate); list.Add(projectCreateInfo); } pRecordCount = q.GetRecordCount(); return(list); }
//从后台获取数据 internal static void LoadFromDAL(ProjectCreateInfo pProjectCreateInfo, ProjectCreate pProjectCreate) { pProjectCreateInfo.projectCreateId = pProjectCreate.ProjectCreateId; pProjectCreateInfo.clientId = pProjectCreate.ClientId; pProjectCreateInfo.projectLevelId = pProjectCreate.ProjectLevelId; pProjectCreateInfo.projectTypeId = pProjectCreate.ProjectTypeId; pProjectCreateInfo.yeWuId = pProjectCreate.YeWuId; pProjectCreateInfo.projectName = pProjectCreate.ProjectName; pProjectCreateInfo.preMoney = pProjectCreate.PreMoney; pProjectCreateInfo.preProfit = pProjectCreate.PreProfit; pProjectCreateInfo.applyDate = pProjectCreate.ApplyDate; pProjectCreateInfo.createPhaseExp = pProjectCreate.CreatePhaseExp; pProjectCreateInfo.proposePhaseExp = pProjectCreate.ProposePhaseExp; pProjectCreateInfo.callbidPhaseExp = pProjectCreate.CallbidPhaseExp; pProjectCreateInfo.talkPhaseExp = pProjectCreate.TalkPhaseExp; pProjectCreateInfo.carryPhaseExp = pProjectCreate.CarryPhaseExp; pProjectCreateInfo.needDescribe = pProjectCreate.NeedDescribe; pProjectCreateInfo.compitDescribe = pProjectCreate.CompitDescribe; pProjectCreateInfo.clientDescribe = pProjectCreate.ClientDescribe; pProjectCreateInfo.techDescribe = pProjectCreate.TechDescribe; pProjectCreateInfo.businessDescribe = pProjectCreate.BusinessDescribe; pProjectCreateInfo.riskDescribe = pProjectCreate.RiskDescribe; pProjectCreateInfo.strategyDesribe = pProjectCreate.StrategyDesribe; pProjectCreateInfo.memo = pProjectCreate.Memo; pProjectCreateInfo.marketView = pProjectCreate.MarketView; pProjectCreateInfo.techView = pProjectCreate.TechView; pProjectCreateInfo.managerView = pProjectCreate.ManagerView; pProjectCreateInfo.sheetNum = pProjectCreate.SheetNum; pProjectCreateInfo.today = pProjectCreate.Today; pProjectCreateInfo.applyName = pProjectCreate.ApplyName; pProjectCreateInfo.departName = pProjectCreate.DepartName; pProjectCreateInfo.state = pProjectCreate.State; pProjectCreateInfo.applyTime = pProjectCreate.ApplyTime; pProjectCreateInfo.Loaded = true; }
public async Task <IActionResult> CreateProject([FromBody][Required] ProjectCreate projectCreate) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } Project project = projectCreate.NewProject(); if (!User.IsInRole("Admin")) { Student student = await _studentService.GetByIdAsync(Int32.Parse(User.Identity.Name)); if (!student.GroupAdmin) { return(BadRequest("You are not group admin.")); } project.Proposed = true; project.Approved = false; student.Group.ProposedProject = project; await _studentService.UpdateAsync(student); return(Ok()); } try { await _projectService.CreateAsync(project); return(Ok()); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public ActionResult Create(ProjectCreate model) { if (!ModelState.IsValid) { var employeeList = new EmployeeRepo(); var customerList = new CustomerRepo(); model.Customers = customerList.GetCustomers(); model.Employees = employeeList.GetEmployees(); return(View(model)); } var service = CreateProjectService(); if (service.CreateProject(model)) { TempData["SaveResult"] = "Project successfully created!"; return(RedirectToAction("Index")); } ; ModelState.AddModelError("", "Project could not be created."); return(View(model)); }
public void GetXmlWithNullValueCustomFieldTest() { string expected = @"<?xml version=""1.0"" encoding=""utf-8""?> <function controlid=""unittest""> <create> <PROJECT> <NAME>hello world</NAME> <PROJECTCATEGORY>Contract</PROJECTCATEGORY> <customfield1 /> </PROJECT> </create> </function>"; ProjectCreate record = new ProjectCreate("unittest") { ProjectName = "hello world", ProjectCategory = "Contract", CustomFields = new Dictionary <string, dynamic> { { "customfield1", null } }, }; this.CompareXml(expected, record); }
//public async Task<IActionResult> Create([Bind("ID,Name,Content,Price,CreatedAt,UpdatedAt")] Project project) public async Task <IActionResult> Create([Bind("ID,Name,Content,Price,Image")] ProjectCreate projectCreate) { Project projectModel = null; if (ModelState.IsValid) { string uniqueFileName = UploadedFile(projectCreate); string fileLocation = HttpContext.Request.Scheme + "://" + this.Request.Host + "/images/" + uniqueFileName; projectModel = new Project { Name = projectCreate.Name, Content = projectCreate.Content, Price = projectCreate.Price, //Picture = uniqueFileName, Picture = fileLocation, }; _context.Add(projectModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(projectModel)); }
ProjectCreate CreateProject(out Project created, string name, bool star) { var p = new ProjectCreate { Description = "desc", ImportUrl = null, IssuesEnabled = true, MergeRequestsEnabled = true, Name = name, NamespaceId = 0, SnippetsEnabled = true, VisibilityLevel = VisibilityLevel.Public, WallEnabled = true, WikiEnabled = true }; created = projects.Create(p); // star is applicable if (star) { created = projects.Star(created.Id); } return(p); }
public async Task <Requirement> Create(ProjectCreate project) { var newProject = new Requirement(); using var transaction = await db.Database.BeginTransactionAsync(); try { newProject = new Requirement() { Name = project.Name, Profile = await File.ReadAllTextAsync(Directory.GetCurrentDirectory() + "/Json/baseProfile.json"), Write = RequirementWrite.CREATED }; await db.Requirements.AddAsync(newProject); await db.SaveChangesAsync(); await transaction.CommitAsync(); } catch { await transaction.RollbackAsync(); throw new ServerErrorException("DB Failed"); } return(newProject); }
public async Task <ActionResult <ProjectStatus> > CreateAProject([FromBody] ProjectCreate project) { var response = await projectsRepository.CreateAProject(project); var viewModel = mapper.Map <ProjectStatus>(response); return(Created("GetAProject", viewModel)); }
public IActionResult CreateProject([FromBody] ProjectCreate model) { var project = _mapper.Map <Project>(model); var user = (User)HttpContext.Items["User"]; project.ProjectCreatorId = user.UserId; _projectService.CreateProject(project); return(Ok()); }
private ProjectCreate getCreateViewModel(ProjectCreateDTO dto) { ProjectCreate viewModel = this.getCreateViewModel(); viewModel.Name = dto.Name; viewModel.ProjectID = dto.ProjectID; viewModel.Rate = dto.Rate; return(viewModel); }
//数据持久化 internal static void SaveToDb(ProjectCreateInfo pProjectCreateInfo, ProjectCreate pProjectCreate, bool pIsNew) { pProjectCreate.ProjectCreateId = pProjectCreateInfo.projectCreateId; pProjectCreate.ClientId = pProjectCreateInfo.clientId; pProjectCreate.ProjectLevelId = pProjectCreateInfo.projectLevelId; pProjectCreate.ProjectTypeId = pProjectCreateInfo.projectTypeId; pProjectCreate.YeWuId = pProjectCreateInfo.yeWuId; pProjectCreate.ProjectName = pProjectCreateInfo.projectName; pProjectCreate.PreMoney = pProjectCreateInfo.preMoney; pProjectCreate.PreProfit = pProjectCreateInfo.preProfit; pProjectCreate.ApplyDate = pProjectCreateInfo.applyDate; pProjectCreate.CreatePhaseExp = pProjectCreateInfo.createPhaseExp; pProjectCreate.ProposePhaseExp = pProjectCreateInfo.proposePhaseExp; pProjectCreate.CallbidPhaseExp = pProjectCreateInfo.callbidPhaseExp; pProjectCreate.TalkPhaseExp = pProjectCreateInfo.talkPhaseExp; pProjectCreate.CarryPhaseExp = pProjectCreateInfo.carryPhaseExp; pProjectCreate.NeedDescribe = pProjectCreateInfo.needDescribe; pProjectCreate.CompitDescribe = pProjectCreateInfo.compitDescribe; pProjectCreate.ClientDescribe = pProjectCreateInfo.clientDescribe; pProjectCreate.TechDescribe = pProjectCreateInfo.techDescribe; pProjectCreate.BusinessDescribe = pProjectCreateInfo.businessDescribe; pProjectCreate.RiskDescribe = pProjectCreateInfo.riskDescribe; pProjectCreate.StrategyDesribe = pProjectCreateInfo.strategyDesribe; pProjectCreate.Memo = pProjectCreateInfo.memo; pProjectCreate.MarketView = pProjectCreateInfo.marketView; pProjectCreate.TechView = pProjectCreateInfo.techView; pProjectCreate.ManagerView = pProjectCreateInfo.managerView; pProjectCreate.SheetNum = pProjectCreateInfo.sheetNum; pProjectCreate.Today = pProjectCreateInfo.today; pProjectCreate.ApplyName = pProjectCreateInfo.applyName; pProjectCreate.DepartName = pProjectCreateInfo.departName; pProjectCreate.State = pProjectCreateInfo.state; pProjectCreate.ApplyTime = pProjectCreateInfo.applyTime; pProjectCreate.IsNew = pIsNew; string UserName = SubsonicHelper.GetUserName(); try { pProjectCreate.Save(UserName); } catch (Exception ex) { LogManager.getInstance().getLogger(typeof(ProjectCreateInfo)).Error(ex); if (ex.Message.Contains("插入重复键")) //违反了唯一键 { throw new AppException("此对象已经存在"); //此处等待优化可以从唯一约束中直接取出提示来,如果没有的话,默认为原始的出错提示 } throw new AppException("保存失败"); } pProjectCreateInfo.projectCreateId = pProjectCreate.ProjectCreateId; //如果缓存存在,更新缓存 if (CachedEntityCommander.IsTypeRegistered(typeof(ProjectCreateInfo))) { ResetCache(); } }
// GET: Create public ActionResult Create() { var model = new ProjectCreate(); var employeeList = new EmployeeRepo(); var customerList = new CustomerRepo(); model.Customers = customerList.GetCustomers(); model.Employees = employeeList.GetEmployees(); return(View(model)); }
public string Get(ProjectCreate request) { if (ImportProject.CreateProj(request.name) == "OK") { return(new OkResponse("create ok").ToString()); } else { return(new FailResponse("false").ToString()); } }
public ActionResult Create(ProjectCreate model) { var service = new ProjectService(); if (ModelState.IsValid) { service.CreateProject(model); return(RedirectToAction("Index")); } return(View(model)); }
private ProjectCreate getCreateViewModel() { var userID = this.User.Identity.GetUserId(); var viewModel = new ProjectCreate(); var rates = this.db.GetUserRatesAsKeyValuePair(userID).ToList(); if (rates.Count == 0) { rates.Add(new KeyValuePair <object, string>(0, "No rates found!")); } viewModel.UserRates = rates; return(viewModel); }
public async Task <IActionResult> CreateProject([FromBody] ProjectCreate project) { try { var newProject = await repository.Create(project); return(Created($"/profiles/{newProject.Id}", newProject.Id)); } catch (RestException ex) { return(ex.SendStatusCode()); } }
private void AddProject_Click(object sender, EventArgs e) { ProjectCreate projectCreate = new ProjectCreate(); if (projectCreate.ShowDialog() == true) { string name = projectCreate.tbxName.Text; string desc = projectCreate.tbxDesc.Text; DateTime date = (DateTime)projectCreate.tbxDate.SelectedDate; controller.CreateProject(name, desc, date); Refresh(); } }
public bool CreateProject(ProjectCreate model) { var entity = new Project() { ProjectID = Guid.NewGuid(), Creator = _userId, Title = model.Title, Desc = model.Desc, CreatedUTC = DateTimeOffset.Now }; Context.Projects.Add(entity); return(Context.TrySave()); }
public static bool IsSheetNumOfProject() { Query q = ProjectCreate.Query(); DataTable dt = q.ExecuteDataSet().Tables[0]; if (dt.Rows.Count > 0) { return(true); } else { return(false); } }
public IHttpActionResult Post(ProjectCreate project) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateProjectService(); if (!service.CreateProject(project)) { return(InternalServerError()); } return(Ok()); }
public Project CreateProject(string projName) { var projs = api.ListProjects(owner: new List <string>() { Helper.CurrentUser.Username }).Resources; var found = projs.FirstOrDefault(_ => _.Name == this.NewProject); var owner = Helper.CurrentUser.Username; var projectCreate = new ProjectCreate(projName); var response = api.CreateProject(owner, projectCreate); var proj = api.GetProject(owner, projName); return(proj); }
public IHttpActionResult Post(ProjectCreate project) { if (!ModelState.IsValid) { return(BadRequest($"Your ModelState is invalid and set to {ModelState}")); } var service = CreateProjectService(); if (!service.CreateProject(project)) { return(InternalServerError()); } return(Ok("You've created a project!")); }
private string UploadedFile(ProjectCreate projectCreate) { string uniqueFileName = null; if (projectCreate.Image != null) { string uploadsFolder = Path.Combine(webHostEnvironment.WebRootPath, "images"); uniqueFileName = Guid.NewGuid().ToString() + "_" + projectCreate.Image.FileName; string filePath = Path.Combine(uploadsFolder, uniqueFileName); using (var fileStream = new FileStream(filePath, FileMode.Create)) { projectCreate.Image.CopyTo(fileStream); } } return(uniqueFileName); }
public ActionResult Create(ProjectCreate model) { if (!ModelState.IsValid) { return(View(model)); } var service = CreateProjectService(); if (service.CreateProject(model)) { TempData["SaveResult"] = "Your Project was created."; return(RedirectToAction("Index")); } return(View(model)); }
public VersionControlSystemInfo CreateRepositoryForProject(CreateProjectRequest request) { var project = new ProjectCreate { IssuesEnabled = false, Description = request.Info, MergeRequestsEnabled = false, Name = request.Name, VisibilityLevel = request.AccessLevel == AccessLevel.Public ? VisibilityLevel.Public : VisibilityLevel.Private }; var createdProject = _gitLabClient.Projects.Create(project); return(new VersionControlSystemInfo(createdProject.Id, new Uri(createdProject.WebUrl))); }
/// <summary> /// 保存 /// </summary> public override void Save() { if (!m_Loaded) //新增 { ProjectCreate projectCreate = new ProjectCreate(); SaveToDb(this, projectCreate, true); } else //修改 { ProjectCreate projectCreate = new ProjectCreate(projectCreateId); if (projectCreate.IsNew) { throw new AppException("该数据已经不存在了"); } SaveToDb(this, projectCreate, false); } }
ProjectCreate CreateProject(out Project created, string name) { var p = new ProjectCreate { Description = "desc", ImportUrl = null, IssuesEnabled = true, MergeRequestsEnabled = true, Name = name, NamespaceId = null, SnippetsEnabled = true, VisibilityLevel = VisibilityLevel.Public, WallEnabled = true, WikiEnabled = true }; created = _projects.Create(p); return(p); }
//从后台获取数据 internal static void LoadFromDAL(ProjectCreateInfo pProjectCreateInfo, ProjectCreate pProjectCreate) { pProjectCreateInfo.projectCreateId = pProjectCreate.ProjectCreateId; pProjectCreateInfo.clientId = pProjectCreate.ClientId; pProjectCreateInfo.projectLevelId = pProjectCreate.ProjectLevelId; pProjectCreateInfo.projectTypeId = pProjectCreate.ProjectTypeId; pProjectCreateInfo.yeWuId = pProjectCreate.YeWuId; pProjectCreateInfo.projectName = pProjectCreate.ProjectName; pProjectCreateInfo.preMoney = pProjectCreate.PreMoney; pProjectCreateInfo.preProfit = pProjectCreate.PreProfit; pProjectCreateInfo.applyDate = pProjectCreate.ApplyDate; pProjectCreateInfo.createPhaseExp = pProjectCreate.CreatePhaseExp; pProjectCreateInfo.proposePhaseExp = pProjectCreate.ProposePhaseExp; pProjectCreateInfo.callbidPhaseExp = pProjectCreate.CallbidPhaseExp; pProjectCreateInfo.talkPhaseExp = pProjectCreate.TalkPhaseExp; pProjectCreateInfo.carryPhaseExp = pProjectCreate.CarryPhaseExp; pProjectCreateInfo.needDescribe = pProjectCreate.NeedDescribe; pProjectCreateInfo.compitDescribe = pProjectCreate.CompitDescribe; pProjectCreateInfo.clientDescribe = pProjectCreate.ClientDescribe; pProjectCreateInfo.techDescribe = pProjectCreate.TechDescribe; pProjectCreateInfo.businessDescribe = pProjectCreate.BusinessDescribe; pProjectCreateInfo.riskDescribe = pProjectCreate.RiskDescribe; pProjectCreateInfo.strategyDesribe = pProjectCreate.StrategyDesribe; pProjectCreateInfo.memo = pProjectCreate.Memo; pProjectCreateInfo.marketView = pProjectCreate.MarketView; pProjectCreateInfo.techView = pProjectCreate.TechView; pProjectCreateInfo.managerView = pProjectCreate.ManagerView; pProjectCreateInfo.sheetNum = pProjectCreate.SheetNum; pProjectCreateInfo.today = pProjectCreate.Today; pProjectCreateInfo.applyName = pProjectCreate.ApplyName; pProjectCreateInfo.departName = pProjectCreate.DepartName; pProjectCreateInfo.state = pProjectCreate.State; pProjectCreateInfo.applyTime = pProjectCreate.ApplyTime; pProjectCreateInfo.Loaded=true; }
/// <summary> /// 保存 /// </summary> public override void Save() { if(!m_Loaded)//新增 { ProjectCreate projectCreate=new ProjectCreate(); SaveToDb(this, projectCreate,true); } else//修改 { ProjectCreate projectCreate=new ProjectCreate(projectCreateId); if(projectCreate.IsNew) throw new AppException("该数据已经不存在了"); SaveToDb(this, projectCreate,false); } }
//数据持久化 internal static void SaveToDb(ProjectCreateInfo pProjectCreateInfo, ProjectCreate pProjectCreate,bool pIsNew) { pProjectCreate.ProjectCreateId = pProjectCreateInfo.projectCreateId; pProjectCreate.ClientId = pProjectCreateInfo.clientId; pProjectCreate.ProjectLevelId = pProjectCreateInfo.projectLevelId; pProjectCreate.ProjectTypeId = pProjectCreateInfo.projectTypeId; pProjectCreate.YeWuId = pProjectCreateInfo.yeWuId; pProjectCreate.ProjectName = pProjectCreateInfo.projectName; pProjectCreate.PreMoney = pProjectCreateInfo.preMoney; pProjectCreate.PreProfit = pProjectCreateInfo.preProfit; pProjectCreate.ApplyDate = pProjectCreateInfo.applyDate; pProjectCreate.CreatePhaseExp = pProjectCreateInfo.createPhaseExp; pProjectCreate.ProposePhaseExp = pProjectCreateInfo.proposePhaseExp; pProjectCreate.CallbidPhaseExp = pProjectCreateInfo.callbidPhaseExp; pProjectCreate.TalkPhaseExp = pProjectCreateInfo.talkPhaseExp; pProjectCreate.CarryPhaseExp = pProjectCreateInfo.carryPhaseExp; pProjectCreate.NeedDescribe = pProjectCreateInfo.needDescribe; pProjectCreate.CompitDescribe = pProjectCreateInfo.compitDescribe; pProjectCreate.ClientDescribe = pProjectCreateInfo.clientDescribe; pProjectCreate.TechDescribe = pProjectCreateInfo.techDescribe; pProjectCreate.BusinessDescribe = pProjectCreateInfo.businessDescribe; pProjectCreate.RiskDescribe = pProjectCreateInfo.riskDescribe; pProjectCreate.StrategyDesribe = pProjectCreateInfo.strategyDesribe; pProjectCreate.Memo = pProjectCreateInfo.memo; pProjectCreate.MarketView = pProjectCreateInfo.marketView; pProjectCreate.TechView = pProjectCreateInfo.techView; pProjectCreate.ManagerView = pProjectCreateInfo.managerView; pProjectCreate.SheetNum = pProjectCreateInfo.sheetNum; pProjectCreate.Today = pProjectCreateInfo.today; pProjectCreate.ApplyName = pProjectCreateInfo.applyName; pProjectCreate.DepartName = pProjectCreateInfo.departName; pProjectCreate.State = pProjectCreateInfo.state; pProjectCreate.ApplyTime = pProjectCreateInfo.applyTime; pProjectCreate.IsNew=pIsNew; string UserName = SubsonicHelper.GetUserName(); try { pProjectCreate.Save(UserName); } catch(Exception ex) { LogManager.getInstance().getLogger(typeof(ProjectCreateInfo)).Error(ex); if(ex.Message.Contains("插入重复键"))//违反了唯一键 { throw new AppException("此对象已经存在");//此处等待优化可以从唯一约束中直接取出提示来,如果没有的话,默认为原始的出错提示 } throw new AppException("保存失败"); } pProjectCreateInfo.projectCreateId = pProjectCreate.ProjectCreateId; //如果缓存存在,更新缓存 if (CachedEntityCommander.IsTypeRegistered(typeof(ProjectCreateInfo))) { ResetCache(); } }
public async Task<ProjectCreate.response> ProjectCreate(ProjectCreate.request request, CancellationToken? token = null) { return await SendAsync<ProjectCreate.response>(request.ToXmlString(), token.GetValueOrDefault(CancellationToken.None)); }
private void LoadFromId(int projectCreateId) { if (CachedEntityCommander.IsTypeRegistered(typeof(ProjectCreateInfo))) { ProjectCreateInfo projectCreateInfo=Find(GetList(), projectCreateId); if(projectCreateInfo==null) throw new AppException("未能在缓存中找到相应的键值对象"); Copy(projectCreateInfo, this); } else { ProjectCreate projectCreate=new ProjectCreate( projectCreateId); if(projectCreate.IsNew) throw new AppException("尚未初始化"); LoadFromDAL(this, projectCreate); } }