public IHttpActionResult PutContactRecord(ICollection <ContactRecordDetail> contactRecordDetail)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            int contactId = contactRecordDetail.FirstOrDefault().ContactId;

            List <ContactRecordDetail> lstDetails = db.ContactRecordDetails.Where(x => x.ContactId.Equals(contactId)).ToList();

            foreach (var item in contactRecordDetail)
            {
                ContactRecordDetail detail = lstDetails.Where(x => x.QuestionId.Equals(item.QuestionId) && x.QuestionText.Equals(item.QuestionText)).FirstOrDefault();
                if (detail != null)
                {
                    item.ContactRecordDetailId = detail.ContactRecordDetailId;
                    db.Entry(detail).CurrentValues.SetValues(item);
                    db.Entry(detail).State = EntityState.Modified;
                }
                else
                {
                    if (item.ContactRecordDetailId.Equals(0) && !string.IsNullOrEmpty(item.QuestionResponseText))
                    {
                        db.ContactRecordDetails.Add(item);
                    }
                }
            }

            db.SaveChanges();
            return(StatusCode(HttpStatusCode.NoContent));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            ContactRecordDetail contactRecordDetail = db.ContactRecordDetails.Find(id);

            db.ContactRecordDetails.Remove(contactRecordDetail);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "ContactRecordDetailId,ContactId,QuestionId,QuestionText,QuestionResponseText,QuestionResponseValue,QuestionKeys")] ContactRecordDetail contactRecordDetail)
 {
     if (ModelState.IsValid)
     {
         db.Entry(contactRecordDetail).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ContactId = new SelectList(db.ContactRecords, "ContactId", "ClientCallId", contactRecordDetail.ContactId);
     return(View(contactRecordDetail));
 }
        // GET: ContactRecordDetails/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ContactRecordDetail contactRecordDetail = db.ContactRecordDetails.Find(id);

            if (contactRecordDetail == null)
            {
                return(HttpNotFound());
            }
            return(View(contactRecordDetail));
        }
        // GET: ContactRecordDetails/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ContactRecordDetail contactRecordDetail = db.ContactRecordDetails.Find(id);

            if (contactRecordDetail == null)
            {
                return(HttpNotFound());
            }
            ViewBag.ContactId = new SelectList(db.ContactRecords, "ContactId", "ClientCallId", contactRecordDetail.ContactId);
            return(View(contactRecordDetail));
        }