protected static IEnumerable <Tuple <string, string> > GetMortgageProperties(li_mortgages m) { var schemeObj = (JObject)JsonConvert.DeserializeObject(m.li_mortgage_types.scheme); var kv = (JObject)JsonConvert.DeserializeObject(m.properties); return(schemeObj.Cast <KeyValuePair <string, JToken> >() .Select(p => new Tuple <string, string>(p.Value.ToString(), kv[p.Key]?.ToString() ?? ""))); }
protected string GenerateDynamicTableData(li_mortgages dataItem) { var schemeObj = (JObject)JsonConvert.DeserializeObject(dataItem.li_mortgage_types.scheme); var kv = (JObject)JsonConvert.DeserializeObject(dataItem.properties); return(schemeObj.Cast <KeyValuePair <string, JToken> >() .Aggregate(new StringBuilder(), (sb, p) => sb.AppendLine($"<td>{kv[p.Key]}</td>")) .ToString()); }
private void LoadAlbum(li_mortgages model, Agp2pEnums.AlbumTypeEnum type, int splittedIndex) { string[] albumArr = GetSplittedFormValue("hid_photo_name", splittedIndex).ToArray(); string[] remarkArr = GetSplittedFormValue("hid_photo_remark", splittedIndex).ToArray(); context.li_albums.DeleteAllOnSubmit(context.li_albums.Where(a => a.mortgage == model.id && a.type == (int)type)); var preAdd = albumArr.Zip(remarkArr, (album, remark) => { var albumSplit = album.Split('|'); return(new li_albums { original_path = albumSplit[1], thumb_path = albumSplit[2], remark = remark, add_time = DateTime.Now, li_mortgages = model, type = (byte)type }); }); context.li_albums.InsertAllOnSubmit(preAdd); }
private bool DoAdd() { var check = context.li_mortgages.FirstOrDefault( q => q.name == txtName.Text.Trim() && q.owner == Convert.ToInt32(owner_id)); //检测标的物是否重复 if (check != null) { JscriptMsg("同一个抵押者的标的物名称有重复!", "", "Error"); return(false); } var model = new li_mortgages { name = txtName.Text.Trim(), owner = Convert.ToInt32(owner_id), type = Convert.ToByte(rblMortgageType.SelectedValue), valuation = Convert.ToDecimal(txtValuation.Text.Trim()), remark = txtRemark.Text.Trim(), properties = txtProperties.Value, last_update_time = DateTime.Now }; context.li_mortgages.InsertOnSubmit(model); LoadAlbum(model, Agp2pEnums.AlbumTypeEnum.Pictures, 0); LoadAlbum(model, Agp2pEnums.AlbumTypeEnum.PropertyCertificate, 1); try { context.SubmitChanges(); AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加标的物:" + model.name); //记录日志 return(true); } catch (Exception ex) { JscriptMsg(ex.Message, "", "Error"); return(false); } }