public JsonResult Insert(StoreProductCollocation collocationInfo) { try { string guid = Guid.NewGuid().ToString().Replace("-", ""); collocationInfo.Guid = guid; collocationInfo.IsDeleted = false; collocationInfo.IsEnabled = true; HttpFileCollectionBase files = Request.Files; OperationResult oper = new OperationResult(OperationResultType.Error); if (files.Count == 0) { oper.Message = "请选择图片"; return(Json(oper)); } else { string conPath = "/Content/UploadFiles/StoreCollocation"; DateTime now = DateTime.Now; Guid gid = Guid.NewGuid(); string fileName = gid.ToString(); conPath = conPath + now.Year.ToString() + "/" + now.Month.ToString() + "/" + now.Day.ToString() + "/" + now.Hour.ToString() + "/" + now.ToString("yyyyMMddHHmmss") + ".jpg"; files[0].SaveAs(FileHelper.UrlToPath(conPath)); collocationInfo.ThumbnailPath = conPath; OperationResult rs = _storeProductCollocationContract.Insert(collocationInfo); return(Json(rs)); } } catch (Exception e) { return(Json(new OperationResult(OperationResultType.Error, "获取失败!", e.Message))); } }
public ActionResult Create() { string guid = Guid.NewGuid().ToString().Replace("-", ""); //删除无效数据 var date = DateTime.Now.Date.AddDays(-1); var items = _storeProductCollocationContract.StoreProductCollocations.Where( x => string.IsNullOrEmpty(x.CollocationName)).Where(x => x.CreatedTime <= date).Select(x => x.Id).ToArray(); if (items.Any()) { _storeCollocationInfoContract.DeleteByCollocationId(items); _storeProductCollocationContract.TrueRemove(items); } //foreach (var a in items) { // if (DateTime.Now.Subtract(a.CreatedTime).TotalDays > 1) // { // } //} _storeProductCollocationContract.Insert(new StoreProductCollocation() { CollocationName = "", Guid = guid }); ViewBag.Styles = GetSelect("风格"); //风格 ViewBag.Situation = GetSelect("场合"); //场合 ViewBag.Season = GetSelect("季节"); ViewBag.Shape = GetSelect("体型"); ViewBag.Effect = GetSelect("效果"); ViewBag.Colour = GetSelect("颜色"); ViewBag.uid = guid; return(PartialView()); }