public ProductMembershipDTO Get(int id) { using (Assignment4Context context = new Assignment4Context()) { ProductMembership pmember = context.ProductMembership.Find(id); return(new ProductMembershipDTO { ID = pmember.ID, ProductId = pmember.ProductId, UserId = pmember.UserId }); } }
public HttpResponseMessage Delete(int id) { using (Assignment4Context context = new Assignment4Context()) { var couldDelete = (User.IsInRole("Admin") || User.IsInRole("Leader")); if (couldDelete) { ProductMembership pmember = context.ProductMembership.Find(id); context.ProductMembership.Remove(pmember); context.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK, "Okay")); } else { return(Request.CreateResponse(HttpStatusCode.OK, new { success = true, message = "Project can't be deleted." })); } } }