public IActionResult Get(int id) { //get user user_dal dal_user = new user_dal(); user current_user = dal_user.getUser(_context); //get travel if (id > 0) { var travel = getById(id); if (travel != null) { return(new OkObjectResult(JsonConvert.SerializeObject(travel, Formatting.None, new JsonSerializerSettings() { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }))); //Loop referencing } else { return(NotFound()); } } else { var travel = new travel(); return(new OkObjectResult(JsonConvert.SerializeObject(travel, Formatting.None, new JsonSerializerSettings() { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }))); } }
private void adddetail(travel source, travel target) { if (source.traveldetail != null && source.traveldetail.Count > 0) { target.traveldetail = new List <traveldetail>(); } foreach (traveldetail detail in source.traveldetail) { target.traveldetail.Add(detail); } }
private void copydata(travel source, travel target) { target.destination = source.destination; target.fromdate = source.fromdate; target.phaseId = source.phaseId; target.projectId = source.projectId; target.purposeId = source.purposeId; target.reason = source.reason; target.todate = source.todate; target.traveltypeId = source.traveltypeId; target.userId = source.userId; }
protected void Page_Load(object sender, EventArgs e) { travel p = new travel(); p.Adapter("select *, '~/user/image/'+pro.img as im from pro"); if (p.dt.Rows.Count != null) { DataList1.DataSource = p.dt; DataList1.DataBind(); } }
public IActionResult Put(int id, [FromBody] travel value) { var travel = _context.travel.Include(t => t.traveldetail).Where(t => t.travelId == id).FirstOrDefault <travel>(); if (travel != null) { copydata(value, travel); _context.SaveChanges(); var send = getById(id); return(Ok(send)); } else { return(NotFound()); } }
public IActionResult Post([FromBody] travel value) { var travel = new travel(); copydata(value, travel); adddetail(value, travel); _context.travel.Add(travel); _context.SaveChanges(); _logger.LogInformation("Travel post"); var send = getById(travel.travelId); return(new OkObjectResult(JsonConvert.SerializeObject(send, Formatting.None, new JsonSerializerSettings() { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }))); //Loop referencing //return Ok(send); }
protected void Button1_Click(object sender, EventArgs e) { travel t = new travel(); t.ReadData("select * from login where phone='" + Txtp.Text + "' and pass='******'"); if (t.dr.Read()) { Session["phone"] = Txtp.Text; string utype = t.dr["status"].ToString(); if (utype == "admin") { Response.Redirect("~/admin/adminhome.aspx"); } else { Response.Redirect("~/user/userhome1.aspx"); } } else { Response.Write("<script>alert('invalid')</script>"); } }