public ActionResult Create(Sell.LendingCars.LendingCarsModel model) { try { Sell.LendingCars.LendingCars LendingCarsRepo = new Sell.LendingCars.LendingCars(); DataLayer.AtsTotalNewDataContext context = new DataLayer.AtsTotalNewDataContext(); if (!LendingCarsRepo.CheckForEdit(model.IDrequstAmani)) { ResultType result = new ResultType(); result.Status = -1; result.ReturnType = 1; result.Message = "وضعیت درخواست تغییر کرده و امکان ویرایش درخواست وجود ندارد "; return(Json(result, JsonRequestBehavior.AllowGet)); } if (model.IDrequstAmani == 0) { var id = LendingCarsRepo.Insert(model); var Code = context.T00050061s.Where(p => p.IDrequstAmani == id).FirstOrDefault().code; ResultType result = new ResultType(); result.Status = 0; result.ReturnType = 1; result.Message = "درخواست امانی ثبت شد"; result.Parameters = new List <Tuple <string, string> >(); result.Parameters.Add(new Tuple <string, string>("Id", id.ToString())); result.Parameters.Add(new Tuple <string, string>("Code", Code)); return(Json(result, JsonRequestBehavior.AllowGet)); } else { LendingCarsRepo.Update(model); //edit contract ResultType result = new ResultType(); result.Parameters = new List <Tuple <string, string> >(); result.Parameters.Add(new Tuple <string, string>("Id", model.IDrequstAmani.ToString())); result.Parameters.Add(new Tuple <string, string>("Code", model.code)); result.Status = 0; result.ReturnType = 1; result.Message = "درخواست امانی ویرایش شد"; return(Json(result, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { ResultType result = new ResultType(); result.Status = 0; result.ReturnType = 1; result.Message = ex.Message; return(Json(result, JsonRequestBehavior.AllowGet)); } }
public ActionResult CheckForEdit(int IdRequestId) { Sell.LendingCars.LendingCars cars = new Sell.LendingCars.LendingCars(); return(Content(cars.CheckForEdit(IdRequestId).ToString())); }