public ActionResult Add(CarModel model) { // 上来先获取当前用户的对象 Member member = _memberBLL.GetMemberByOpenId(System.Web.HttpContext.Current.Session["member"].ToString()); // 传递的参数 是否为空 if (model == null) { return(Json("NullParam", JsonRequestBehavior.AllowGet)); } // 再判断 车牌是否相同 if (_carBLL.IsExist(model.Numberplate.Trim())) { return(Json("ExistNumber", JsonRequestBehavior.AllowGet)); } // 添加新车 Car car = new Car(); car.Id = Guid.NewGuid(); car.IsDeleted = false; car.MemberId = member.Id; car.Numberplate = model.Numberplate.Trim(); car.EngineNumber = model.EngineNumber.Trim(); car.DeletedTime = DateTime.MinValue.AddHours(8); car.CreatedTime = DateTime.Now; car.ChassisNumber = model.ChassisNumber.Trim(); car.CarDetailInfo = model.CarDetailInfo.Trim(); if (_carBLL.Add(car)) { return(Json("True", JsonRequestBehavior.AllowGet)); } else { return(Json("False", JsonRequestBehavior.AllowGet)); } }
public IActionResult Post([FromBody] Car value) { return(Json(_carBLL.Add(value))); }