public IHttpActionResult PutTblcustomer(int id, Tblcustomer tblcustomer) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != tblcustomer.customerID) { return(BadRequest()); } db.Entry(tblcustomer).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!TblcustomerExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PostTblcustomer(Tblcustomer tblcustomer) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Tblcustomers.Add(tblcustomer); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = tblcustomer.customerID }, tblcustomer)); }
public IHttpActionResult DeleteTblcustomer(int id) { Tblcustomer tblcustomer = db.Tblcustomers.Find(id); if (tblcustomer == null) { return(NotFound()); } db.Tblcustomers.Remove(tblcustomer); db.SaveChanges(); return(Ok(tblcustomer)); }
public Tblcustomer GetUserClaims() { var identityClaims = (ClaimsIdentity)User.Identity; IEnumerable <Claim> claims = identityClaims.Claims; Tblcustomer model = new Tblcustomer() { customerID = Convert.ToInt32(identityClaims.FindFirst("customerID").Value), firstname = identityClaims.FindFirst("firstname").Value, lastname = identityClaims.FindFirst("lastname").Value, email = identityClaims.FindFirst("email").Value, password = identityClaims.FindFirst("password").Value, phone = identityClaims.FindFirst("phone").Value }; return(model); }