public ActionResult AddRepay(string key) { var msg = new JsonMessage(false, "Thêm mới dữ liệu thành công !"); try { var model = new Repay(); if (key != Keyapi) { return(Json(0, JsonRequestBehavior.AllowGet)); } UpdateModel(model); model.Note = HttpUtility.UrlDecode(model.Note); model.IsDelete = false; model.IsActive = true; model.Code = DateTime.Now.ToString("yyMMddHHmm"); var startDate = Request["DateReturn_"]; model.DateReturn = startDate.StringToDecimal(); model.DateCreated = DateTime.Now.TotalSeconds(); _da.AddRepay(model); _da.Save(); } catch (Exception ex) { msg.Erros = true; msg.Message = "Dữ liệu chưa được thêm mới."; } return(Json(msg, JsonRequestBehavior.AllowGet)); }
public ActionResult <Loan> RepayLoan([FromRoute] int id, [FromBody] Repay repay) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var loan = _context.Loan.Find(id); if (loan == null) { return(BadRequest()); } loan.RepaymentDate = repay.RepaymentDate; _context.SaveChanges(); return(Ok(loan)); }
static void Main(string[] args) { string path = @$ "D:\Moudel 2\ExceptDemo\Baitap1DeMo\input.json"; PayLoad payload = new PayLoad() { courses = new List <Course>() }; using (StreamReader sr = File.OpenText(path)) { var data = sr.ReadToEnd(); payload = JsonConvert.DeserializeObject <PayLoad>(data); foreach (Course pb in payload.courses) { Console.WriteLine($"{pb.van} {pb.su} {pb.dia}"); } } Repay repay = new Repay() { Sumtotal = new List <total>() }; foreach (Course pb in payload.courses) { repay.Sumtotal.Add(new total { sum = pb.van + pb.su + pb.dia }); } using (StreamWriter sw = File.CreateText($@"{path}output.json")) { var pay = JsonConvert.SerializeObject(repay); sw.WriteLine(pay); } using (StreamWriter swr = File.CreateText($@"{path}output2.json")) { Tichxx repay2 = new Tichxx() { number = new List <Tichx>() }; foreach (Course pb in payload.courses) { repay2.number.Add(new Tichx() { xvan = pb.van * 2, xsu = pb.su * 2, xdia = pb.dia * 2 }); } var hala = JsonConvert.SerializeObject(repay2); swr.WriteLine(hala); } ResData resdata = new ResData() { tich = new List <Data>() }; using (StreamWriter swr = File.CreateText($@"{path}output3.json")) { foreach (Course pb in payload.courses) { resdata.tich.Add(new Data() { a = pb.van * 3, b = pb.su * 3, c = pb.dia * 3 }); } var hala = JsonConvert.SerializeObject(resdata); swr.WriteLine(hala); } }
public void AddRepay(Repay item) { FDIDB.Repays.Add(item); }