public ShopsecurityInfo Save() { if (this.Shop_id != null) { Shopsecurity.Update(this); return(this); } return(Shopsecurity.Insert(this)); }
public APIReturn _Edit([FromQuery] uint Shop_id, [FromForm] string Idcard, [FromForm] string Idcard_img1, [FromForm] string Idcard_img2, [FromForm] string License_img, [FromForm] IFormFile License_img_file) { ShopsecurityInfo item = Shopsecurity.GetItem(Shop_id); if (item == null) { return(APIReturn.记录不存在_或者没有权限); } if (!string.IsNullOrEmpty(item.License_img) && (item.License_img != License_img || License_img_file != null)) { string path = System.IO.Path.Combine(AppContext.BaseDirectory, item.License_img); if (System.IO.File.Exists(path)) { System.IO.File.Delete(path); } } if (License_img_file != null) { item.License_img = $"/upload/{Guid.NewGuid().ToString()}.png"; using (FileStream fs = new FileStream(System.IO.Path.Combine(AppContext.BaseDirectory, item.License_img), FileMode.Create)) License_img_file.CopyTo(fs); } else { item.License_img = License_img; } item.Idcard = Idcard; item.Idcard_img1 = Idcard_img1; item.Idcard_img2 = Idcard_img2; int affrows = Shopsecurity.Update(item); if (affrows > 0) { return(APIReturn.成功.SetMessage($"更新成功,影响行数:{affrows}")); } return(APIReturn.失败); }