public ActionResult Audit(long Id, byte Status, string AuditExplan) { var model = new Entitys.CarInfo() { Id = Id, AuditExplan = AuditExplan, AuditPerson = Common.FormsTicket.UserId, AuditStatus = Status, AuditTime = DateTime.Now, }; var line = provider.Audit(model); return(Json(new { d = line > 0 ? 1 : 0 })); }
public ActionResult Save(Models.CarInfoModels.CarInfoModel model, string ImgList, string ImgDelete) { //TODO:如果已审核不给修改 if (!string.IsNullOrEmpty(model.Id)) { var car = provider.GetCarById(Common.ToolHelper.ConvertToLong(model.Id)); if (car.AuditStatus != (int)Common.EnumModel.EAuditStatus.Normal) { return(Json(new { d = -1 })); } } #region 图片处理 var VehicleLicense = new Common.FileHelper().SaveImgRelative("VehicleLicense", "", Common.FileConfig.OtherPhotoPath); var TestReport = new Common.FileHelper().SaveImgRelative("TestReport", "", Common.FileConfig.OtherPhotoPath); var temp = ImgList.Split(new char[] { ',' }); var photoId = new List <string>(); foreach (var item in temp) { var pid = new Common.FileHelper().SaveImgRelative(item, "", Common.FileConfig.CarPhotoPath); if (!string.IsNullOrEmpty(pid)) { photoId.Add(pid); } } var PhotoURL = new Common.FileHelper().SaveImgRelative("PhotoURL", "", Common.FileConfig.CarPhotoPath); var random = Common.PrimaryKey.GetHashCodeID.ToString(); string FilePath = Common.FileConfig.TempPath + random.Substring(0, 4) + "/" + random.Substring(4) + "/"; model.Remark = model.Remark == null ? model.Remark = "" : model.Remark; model.Remark = MoveContentImage(model.Remark, FilePath); #endregion var t = UserControl.SelectItem.CarTypeItem(model.TypeId, false).Where(c => c.Value == model.TypeId.ToString()).FirstOrDefault(); var s = UserControl.SelectItem.CarSeriesItem(model.BrandId, model.SeriesId, false).Where(c => c.Value == model.SeriesId.ToString()).FirstOrDefault(); var b = UserControl.SelectItem.CarBrandItem(model.BrandId, false).Where(c => c.Value == model.BrandId.ToString()).FirstOrDefault(); var carInfo = new Entitys.CarInfo() { SeriesId = model.SeriesId, SweptVolume = model.SweptVolume, ProductAddress = model.ProductAddress, BrandId = model.BrandId, CarColor = model.CarColor == null ? "" : model.CarColor, CarName = model.CarName == null ? "" : model.CarName, EmissionStandards = model.EmissionStandards, Fuel = model.Fuel, LicenseTime = model.LicenseTime, Odometer = model.Odometer, Remark = model.Remark == null ? "" : model.Remark, RetailPrice = model.RetailPrice, TestReport = TestReport, Transmission = model.Transmission, TypeId = model.TypeId, VehicleLicense = VehicleLicense, VIN = model.VIN == null ? "" : model.VIN, TypeName = t == null ? "" : t.Text, BrandName = b == null ? "" : b.Text.Substring(1, b.Text.Length - 1), SeriesName = s == null ? "" : s.Text, UserId = Common.FormsTicket.UserId, IsRepay = model.IsRepay, PhotoURL = PhotoURL, }; if (!string.IsNullOrEmpty(model.Id)) { //修改 carInfo.Id = Common.ToolHelper.ConvertToLong(model.Id); } else { //新增 carInfo.Id = Common.PrimaryKey.GetHashCodeID; carInfo.AuditStatus = (byte)Common.EnumModel.EAuditStatus.Normal; carInfo.AuditExplan = ""; carInfo.AuditPerson = Common.Constant.LONG_DEFAULT; carInfo.AuditTime = DateTime.Now; carInfo.CarNo = Common.FormsTicket.CarNo; carInfo.CarStatus = model.CarStatus; carInfo.CreateTime = DateTime.Now; carInfo.IsDelete = (byte)Common.EnumModel.EIsDelete.NotDelete; carInfo.TimeStamp = DateTime.Now; } var pModel = new List <Entitys.CarPhoto>(); foreach (var item in photoId) { pModel.Add(new Entitys.CarPhoto { Id = Common.PrimaryKey.GetHashCodeID, CarId = carInfo.Id, PhotoStatus = 0, PhotoType = 0, PhotoURL = item, IsDelete = (byte)Common.EnumModel.EIsDelete.NotDelete, TimeStamp = DateTime.Now, }); } var line = provider.Edit(carInfo, pModel, string.IsNullOrEmpty(model.Id), ImgDelete); return(Json(new { d = line > 0 ? 1 : 0 })); }
public ActionResult Save(Models.CarInfoModels.CarInfoModel model, FormCollection conllection) { string ImgList = conllection["ImgList"]; string ImgDelete = conllection["ImgDelete"]; //TODO:如果已审核不给修改 if (!string.IsNullOrEmpty(model.Id)) { var car = provider.GetCarById(Common.ToolHelper.ConvertToLong(model.Id)); if (car.AuditStatus != (int)Common.EnumModel.EAuditStatus.Normal) { return(Json(new { d = -1 })); } } #region 图片处理 //保存行驶证图片 var VehicleLicense = new Common.FileHelper().SaveImgRelative("VehicleLicense", "", Common.FileConfig.OtherPhotoPath); //车源主图 var PhotoURL = new Common.FileHelper().SaveImgRelative("PhotoURL", "", Common.FileConfig.CarPhotoPath); //车子图片 var temp = ImgList.Split(new char[] { ',' }); var photoId = new List <string>(); foreach (var item in temp) { // var pid = new Common.FileHelper().SaveImgRelative(item, "", Common.FileConfig.CarPhotoPath); if (!string.IsNullOrEmpty(item)) { photoId.Add(item); } } ///保存测试报告 var TestReport = new Common.FileHelper().SaveImgRelative("TestReport", "", Common.FileConfig.OtherPhotoPath); #endregion var t = CarTypeItem(model.TypeId, false).Where(c => c.Value == model.TypeId.ToString()).FirstOrDefault(); var s = CarSeriesItem(model.BrandId, model.SeriesId, false).Where(c => c.Value == model.SeriesId.ToString()).FirstOrDefault(); var b = CarBrandItem(model.BrandId, false).Where(c => c.Value == model.BrandId.ToString()).FirstOrDefault(); var carInfo = new Entitys.CarInfo() { SeriesId = model.SeriesId, SweptVolume = model.SweptVolume, ProductAddress = model.ProductAddress, BrandId = model.BrandId, CarColor = model.CarColor == null ? "" : model.CarColor, CarName = model.CarName == null ? "" : model.CarName, EmissionStandards = model.EmissionStandards, Fuel = model.Fuel, LicenseTime = model.LicenseTime, Odometer = model.Odometer, Remark = model.Remark == null ? "" : model.Remark, RetailPrice = model.RetailPrice, TestReport = TestReport, Transmission = model.Transmission, TypeId = model.TypeId, VehicleLicense = VehicleLicense, VIN = model.VIN == null ? "" : model.VIN, TypeName = t == null ? "" : t.Text, BrandName = b == null ? "" : b.Text.Substring(1, b.Text.Length - 1), SeriesName = s == null ? "" : s.Text, UserId = Common.FormsTicket.UserId, IsRepay = model.IsRepay, PhotoURL = PhotoURL }; if (!string.IsNullOrEmpty(model.Id)) { //修改 carInfo.Id = Common.ToolHelper.ConvertToLong(model.Id); long oid = -1; long.TryParse(model.Id, out oid); var pt = provider.GetCarPhotoById(oid); var listDElID = pt.ToList(); var strlistDElID = listDElID.Where(x => !photoId.Contains(x.PhotoURL)).Select(x => x.Id).ToList(); ImgDelete = string.Join(",", strlistDElID); } else { //新增 carInfo.Id = Common.PrimaryKey.GetHashCodeID; carInfo.AuditStatus = (byte)Common.EnumModel.EAuditStatus.Normal; carInfo.AuditExplan = ""; carInfo.AuditPerson = Common.Constant.LONG_DEFAULT; carInfo.AuditTime = DateTime.Now; carInfo.CarNo = Common.FormsTicket.CarNo; carInfo.CarStatus = model.CarStatus; carInfo.CreateTime = DateTime.Now; carInfo.IsDelete = (byte)Common.EnumModel.EIsDelete.NotDelete; carInfo.TimeStamp = DateTime.Now; } var pModel = new List <Entitys.CarPhoto>(); foreach (var item in photoId) { pModel.Add(new Entitys.CarPhoto { Id = Common.PrimaryKey.GetHashCodeID, CarId = carInfo.Id, PhotoStatus = 0, PhotoType = 0, PhotoURL = item, IsDelete = (byte)Common.EnumModel.EIsDelete.NotDelete, TimeStamp = DateTime.Now, }); } var line = 1; try { provider.Edit(carInfo, pModel, string.IsNullOrEmpty(model.Id), ImgDelete); } catch (Exception ex) { line = 0; } return(Json(new { d = line > 0 ? 1 : 0 })); }