public HttpResponseMessage put(CustomerIssue custisue) { try { var identity = User.Identity as ClaimsIdentity; int compid = 0, userid = 0; foreach (Claim claim in identity.Claims) { if (claim.Type == "compid") { compid = int.Parse(claim.Value); } if (claim.Type == "userid") { userid = int.Parse(claim.Value); } } var CI = db.CustomerIssuedb.Where(c => c.CS_id == custisue.CS_id && c.Deleted == false).SingleOrDefault(); if (CI != null) { CI.Issue = custisue.Issue; CI.Status = custisue.Status; CI.UpdatedDate = indianTime; db.CustomerIssuedb.Attach(CI); db.Entry(CI).State = EntityState.Modified; db.SaveChanges(); } return(Request.CreateResponse(HttpStatusCode.OK, CI)); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message)); } }
public HttpResponseMessage add(CustomerIssue custise) { try { var identity = User.Identity as ClaimsIdentity; int compid = 0, userid = 0; foreach (Claim claim in identity.Claims) { if (claim.Type == "compid") { compid = int.Parse(claim.Value); } if (claim.Type == "userid") { userid = int.Parse(claim.Value); } } custise.Status = "Pending"; custise.CreatedDate = indianTime; custise.UpdatedDate = indianTime; custise.Active = true; custise.Deleted = false; var peo = db.Peoples.Where(p => p.PeopleID == custise.PeopleID).FirstOrDefault(); if (peo != null) { custise.PeopleName = peo.DisplayName; } var cust = db.Customers.Where(p => p.CustomerId == custise.CustomerId).FirstOrDefault(); if (cust != null) { custise.ShopName = cust.ShopName; custise.Mobile = cust.Mobile; } db.CustomerIssuedb.Add(custise); db.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK, custise)); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message)); } }