public static Screen.Vc.WebRole.Models.CompanySummary Convert(Model.CompanySummary src) { CompanySummary target = new CompanySummary() { Id = src.CompanyId, LogoUrl = src.LogoUrl, Name = src.Name }; return(target); }
private void Save() { AjaxResult result = new AjaxResult(); result.IsSuccess = false; result.Msg = "保存失败!"; int id = 0; if (!string.IsNullOrEmpty(Request.Form["id"])) { id = Convert.ToInt32(Request.Form["id"]); var model = bll.Get(id); model.Title = Request.Form["Title"]; model.ModifiedTime = DateTime.Parse(Request.Form["ModifiedTime"]); model.Summary = Server.HtmlDecode(Request.Form["Summary"]); model.SummaryCode = Server.HtmlDecode(Request.Form["SummaryCode"]); model.State = "0"; if (bll.Update(model)) { result.IsSuccess = true; result.Msg = "更新成功!"; } } else { var model = new CompanySummary(); model.Title = Request.Form["Title"]; model.ModifiedTime = DateTime.Parse(Request.Form["ModifiedTime"]); model.Summary = Server.HtmlDecode(Request.Form["Summary"]); model.SummaryCode = Server.HtmlDecode(Request.Form["SummaryCode"]); model.ModifiedBy = User.ID; model.ModifiedByName = User.UserName; model.CompanyName = User.CompanyName; model.ActorID = User.ID; model.State = "0"; if (bll.Add(model)) { result.IsSuccess = true; result.Msg = "增加成功!"; } } Response.Clear(); Response.Write(result.ToJsonString()); Response.ContentType = "application/json"; Response.End(); }
private void Init() { CompanySummary cs = new CompanySummary { ModifiedBy = User.ID, ModifiedByName = User.UserName, ModifiedTime = DateTime.Today, CompanyName = User.CompanyName }; var strJSON = string.Empty; strJSON = JsonConvert.SerializeObject(cs); Response.Clear(); Response.Write(strJSON); Response.ContentType = "application/json"; Response.End(); }
public async Task <IHttpActionResult> UpdateAsync([FromBody] CompanySummary company) { //var companyEntity = TypeAdapter.Adapt<CompanySummary, CompanyEntity>(company); var results = new CompanySummaryValidator().Validate(company); if (!results.IsValid) { return(this.BadRequest(string.Join(" , ", results.Errors))); } var companyEntity = company.ToEntity(); var updatedCompany = await Task.Run(() => _companyAppService.Update(companyEntity)); var viewModel = TypeAdapter.Adapt <CompanyEntity, CompanySummary>(updatedCompany); return(this.Ok(viewModel)); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(CompanySummary model) { return(dal.Update(model) > 0); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(CompanySummary model) { return(dal.Add(model) > 0); }
protected override void ParseData(SqlDataReader dataReader) { // ResultSet 0 contains CompanySummary CompanySummary = new List <CompanySummary>(); while (dataReader.Read()) { CompanySummary companySummary = new CompanySummary() { CompanyId = Convert.ToInt64(dataReader[ColumnName.CompanyId]), Name = Convert.ToString(dataReader[ColumnName.Name]), LogoUrl = Convert.ToString(dataReader[ColumnName.LogoUrl]) }; CompanySummary.Add(companySummary); } // ResultSet 1 contains UnreadQuestionsSummary dataReader.NextResult(); UnreadQuestionsSummary = new Dictionary <Int64, UnreadQuestionsSummary>(); while (dataReader.Read()) { UnreadQuestionsSummary questionsSummary = new UnreadQuestionsSummary() { CompanyId = Convert.ToInt64(dataReader[ColumnName.CompanyId]), UnreadQuestionCount = Convert.ToInt32(dataReader[ColumnName.UnreadQuestionCount]) }; UnreadQuestionsSummary.Add(questionsSummary.CompanyId, questionsSummary); } // ResultSet 2 contains UnreadCommentsSummary dataReader.NextResult(); UnreadCommentsSummary = new Dictionary <Int64, UnreadCommentsSummary>(); while (dataReader.Read()) { UnreadCommentsSummary commentsSummary = new UnreadCommentsSummary() { CompanyId = Convert.ToInt64(dataReader[ColumnName.CompanyId]), UnreadCommentsCount = Convert.ToInt32(dataReader[ColumnName.UnreadCommentsCount]) }; UnreadCommentsSummary.Add(commentsSummary.CompanyId, commentsSummary); } // ResultSet 3 contains MatchingInvestors dataReader.NextResult(); MatchingInvestors = new Dictionary <Int64, IList <MatchingInvestor> >(); while (dataReader.Read()) { IList <MatchingInvestor> investorList; MatchingInvestor investor = new MatchingInvestor() { CompanyId = Convert.ToInt64(dataReader[ColumnName.CompanyId]), InvestorUserId = Convert.ToInt32(dataReader[ColumnName.InvestorUserId]), IndustryId = Convert.ToInt32(dataReader[ColumnName.IndustryId]), IndustryName = Convert.ToString(dataReader[ColumnName.Name]) }; if (!MatchingInvestors.TryGetValue(investor.CompanyId, out investorList)) { investorList = new List <MatchingInvestor>(); MatchingInvestors.Add(investor.CompanyId, investorList); } investorList.Add(investor); } }