title: Showing Intenal Server Error Insert values using MVC
body: <h2>    Controller:</h2>
  
  <p>// Controller For Save Details///
      [HttpPost]
       SaveTeam Task Details WebService and WCF Service no issues in that layer am facing issue for internal server Error.</p>
  
  <pre><code> public async Task&lt;JsonResult&gt; SaveTeamTaskDetails(string jsClient)
          {
  
              var TeamTask = System.Web.Helpers.Json.Decode&lt;TeamTaskClaimSave&gt;(jsClient);
              var xml = TeamTask.Serialize("TeamTaskDetails");
              var result = await this.handsService.SaveTeamTaskDetails(xml);
  
              if (result.Data == null)
                  this.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
  
              return null;
          }
  </code></pre>
  
  <h2>Model:</h2>
  
  <p>// Model Values to Retrieve//</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  using System.Xml.Serialization;
  
  using System.Web.Mvc;
  namespace Equip.Areas.ClinicalReview.Models
  {
      [XmlType("TeamTaskClaimSave")]
  
      public class TeamTaskClaimSave
      {
          [XmlElement("Assigineeid")]
          public int Assigineeid { get; set; }
  
          [XmlElement("AssigineeList")]
          public List&lt;TeamTaskClaimDetails&gt; AssigineeList { get; set; }
  
          [XmlElement("ID")]
          public int ID { get; set; }
          //public string claimid { get; set; }
  
          [XmlElement("claimid")]
          public List&lt;SelectListItem&gt; claimid { get; set; }
  
          [XmlElement("contactID")]
          public string contactID { get; set; }
  
          [XmlElement("taskpriority")]
          public string taskpriority { get; set; }
  
          [XmlElement("Creator")]
          public string Creator { get; set; }
  
          [XmlElement("Description")]
          public string Description { get; set; }
  
          [XmlElement("status")]
          public string status { get; set; }
          [XmlElement("StartDate")]
          public string StartDate { get; set; }
  
          [XmlElement("EndDate")]
          public string EndDate { get; set; }
  
          [XmlElement("ForensicDueDate")]
          public string ForensicDueDate { get; set; }
  
          [XmlElement("ForensicDueTime")]
          public string ForensicDueTime { get; set; }
  
          [XmlElement("PatientFirstName")]
          public string PatientFirstName { get; set; }
  
          [XmlElement("PatientLastName")]
          public string PatientLastName { get; set; }
  
  
          [XmlElement("Client")]
          public string Client { get; set; }
  
          [XmlElement("ProviderName")]
          public string ProviderName { get; set; }
  
          [XmlElement("FirstName")]
          public string FirstName { get; set; }
          [XmlElement("LastName")]
          public string LastName { get; set; }
  
          [XmlElement("PreScreen")]
          public string PreScreen { get; set; }
  
  
          [XmlElement("Priority")]
          public string Priority { get; set; }
  
          [XmlElement("Edit")]
          public string Edit { get; set; }
  
  
          [XmlElement("Comment")]
          public string Comment { get; set; }
  
          [XmlElement("Assiginee")]
          public string Assiginee
          {
              get
              {
                  return string.Format("{0} {1}", this.FirstName ?? string.Empty, this.LastName ?? string.Empty).Trim();
              }
              set
              {
  
              }
  
          }
          [XmlElement("Patient")]
          public string Patient
          {
              get
              {
                  return string.Format("{0} {1}", this.PatientFirstName ?? string.Empty, this.PatientLastName ?? string.Empty).Trim();
              }
  
          }
  
   }
  
  }
  </code></pre>
  
  <h2>View:</h2>
  
  <p>// Values to for View//</p>
  
  <pre><code> @{
      var isReadOnly = ViewBag.IsReadOnly;
      var claimid = ViewBag.claimid as string;
      var FirstName = ViewBag.FirstName as string;
      var cid = ViewBag.contactid as string;
      var isCreate = string.IsNullOrWhiteSpace(claimid) || claimid == "0";
      Layout = null;
  }
  
  @model Equip.Areas.ClinicalReview.Models.TeamTaskClaimSave
  
  
  
  &lt;style&gt;
      label {
          color: rgb(51,51,51);
          font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
          font-size: 12px;
          font-weight: bold;
      }
  &lt;/style&gt;
  
  &lt;div id="clinicalreview-TeamTaskcontainer" class="dialog"&gt;&lt;/div&gt;
  &lt;div id="clinicalreview-addTeamTask-container"&gt;
      &lt;div class="col-xs-12"&gt;
          &lt;label for="clinicalreview-addpayment-dateposted"&gt;Create Date:&lt;/label&gt;
          @Html.TextBoxFor(m =&gt; m.StartDate, new { @style = "width: 380px;height:35px;", @class = "form-control", @readonly = "readonly" })
      &lt;/div&gt;
      &lt;div class="col-xs-12"&gt;
          &lt;label for="clinicalreview-addpayment-amount"&gt;Due Date:&lt;/label&gt;
          @Html.TextBoxFor(m =&gt; m.EndDate, new { @style = "width: 380px;height:35px;", @class = "form-control", @readonly = "readonly" })
      &lt;/div&gt;
      &lt;div class="col-xs-12"&gt;
          &lt;label for="clinicalreview-addpayment-applytoclaim"&gt;Start Date:&lt;/label&gt;
          @Html.TextBoxFor(m =&gt; m.ForensicDueDate, new { @style = "width: 380px;height:35px;", @class = "form-control ", @readonly = "readonly" })
      &lt;/div&gt;
  
      &lt;div class="col-xs-12"&gt;
          &lt;label for="clinicalreview-addpayment-applytoclaim"&gt;Assigned To:&lt;/label&gt;
  
  
  
          @Html.DropDownListFor(m =&gt; m.claimid, new SelectList(ViewBag.Task, "Value", "Text"), new { @style = "width: 380px;height:35px;", @class = "form-control " })
  
      &lt;/div&gt;
  
      &lt;div class="col-xs-12"&gt;
          &lt;label for="clinicalreview-addpayment-applytoclaim"&gt;Priority:&lt;/label&gt;
  
          @* @Html.DropDownListFor(m =&gt; m.claimid, new SelectList(ViewBag.TaskPriority, "Value", "Text"), new { @style = "width: 380px;height:35px;", @class = "form-control " })*@
  
          @Html.DropDownList("Priority", new List&lt;SelectListItem&gt;
             {
               new SelectListItem{ Text="HIGH", Value = "1" },
               new SelectListItem{ Text="LOW", Value = "2" },
               new SelectListItem{ Text="MEDIUM", Value = "3" },
              }, new { @style = "width: 180px;height:30px;", @class = "form-control" })
      &lt;/div&gt;
  
      &lt;div class="col-xs-12"&gt;
          &lt;label for="clinicalreview-addpayment-applytoclaim"&gt;Comment:&lt;/label&gt;
          @Html.TextAreaFor(m =&gt; m.Comment, new { @class = "form-control date" })
      &lt;/div&gt;
      &lt;div class="col-xs-12" style="margin-top: 10px;"&gt;&lt;/div&gt;
      &lt;div class="form-group col-xs-6"&gt;
          @*&lt;button type="button" class="btn btn-primary col-xs-12" id="btnSubmit"&gt;*@
  
          &lt;button type="button" id="btnSubmit" data-bind="click: $root.create"&gt;
              &lt;span&gt;Save&lt;/span&gt;
          &lt;/button&gt;
      &lt;/div&gt;
  
  &lt;/div&gt;
  
  
  
  &lt;script type="text/javascript"&gt;
  
          function TeamTaskDetailedValues(value) {
  
          }
  
          function TeamTaskViewModel() {
              var self = this;
  
              self.StartDate = ko.observable("");
              self.EndDate = ko.observable("");
              self.ForensicDueDate = ko.observable("");
              self.claimid = ko.observable("");
              self.Comment = ko.observable("");
  
              var Team = {
                  StartDate: self.StartDate,
                  EndDate: self.EndDate,
                  ForensicDueDate: self.ForensicDueDate,
                  claimid: self.claimid
              };
  
              self.Team = ko.observable();
              self.Teams = ko.observableArray();
  
  
  
              self.create = function () {
                  //if (Team.StartDate() != "" &amp;&amp; Team.EndDate() != "" &amp;&amp; Team.ForensicDueDate() != "")
                  //{
                      $.ajax({
                          url: '@Url.Action("SaveTeamTaskDetails", "ClinicalReviewDataScreen")',
                          cache: false,
                          type: 'POST',
                          contentType: 'application/json; charset=utf-8',
                          data: ko.toJSON(Team),
                          success: function (data) {
                              self.Teams.push(data);
                              self.StartDate("");
                              self.EndDate("");
                              self.ForensicDueDate("");
                              self.claimid("");
  
                          }
                      }).fail(
                           function (xhr, textStatus, err) {
                               alert(err);
                           });
  
                  //}
                  //else {
                  //    alert('Please Enter All the Values !!');
                  //}
  
              }
  
                      self.cancel = function () {
                      self.Team(null);
  
                  }
              }
                            var viewModel = new TeamTaskViewModel();
                            ko.applyBindings(viewModel);
  
  &lt;/script&gt;
  </code></pre>
  
  <h2>Stored Procedure:</h2>
  
  <h2>Stored Procedure to Insert Values :</h2>
  
  <pre><code>SET ANSI_NULLS ON
  GO
  SET QUOTED_IDENTIFIER ON
  GO
  ALTER proc [dbo].[Equip_SaveTeamTaskAssigineeDetails] (
  @saveDataXML xml)
  AS
  BEGIN
  
    DECLARE @claimid INT ,
      @createdate DATETIME ,
      @duedate DATETIME ,
      @startdate DATETIME ,
      @assignmentid INT ,
      @assignedto VARCHAR(50) ,
      @piority VARCHAR(50) ,
      @comment VARCHAR(4000)
  
  SELECT  @claimid = node.value('@claimid', 'int') ,
          @createdate = node.value('@createdate', 'datetime') ,
          @duedate = node.value('@duedate', 'datetime') ,
          @startdate = node.value('@startdate', 'datetime') ,
          @assignmentid = node.value('@assignmentid', 'int') ,
          @assignedto = node.value('@assignedto', 'varchar(50)') ,
          @piority = node.value('@piority', 'varchar(50)') ,
          @comment = node.value('@comment', 'varchar(4000)')
  FROM    @saveDataXML.nodes('/TeamTaskDetails/Task') nodes ( node )  
  
  
  SELECT  claimid = @claimid ,
          createdate = @createdate ,
          duedate = @duedate ,
          startdate = @startdate ,
          assignedid = @assignedto ,
          assiginedto = @assignedto ,
          priority = @piority ,
          comment = @comment
  
      IF (@claimid != 0) BEGIN
          INSERT INTO  [dbo].[TeamTaskAssiginment]
                 ([claimid],
                  [createdate],
                  [duedate],
                  [startdate],
                  [assignedid],
                  [assiginedto],
                  [priority],
                  [comment])
  
  
  
  
               VALUES
              (@claimid,
              @createdate,
              @duedate,
              @startdate ,
              @assignmentid ,
              @assignedto ,
              @piority ,
              @comment
                  )
  
           END ELSE BEGIN
              Update [dbo].[TeamTaskAssiginment] set
  
  
                   claimid=@claimid ,
                  createdate=@createdate,
                  duedate=@duedate,
                  startdate=@startdate,
                  assignedid=@assignedto,
                  assiginedto=@assignedto,
                  priority=@piority,
                  comment=@comment
  
        END
  END
  </code></pre>
  
  <p>Please Any one Help To Resolve the issue.</p>