I m working the crudoperation mvc with api but when I click edit record then give an error:
The parameters dictionary contains a null entry for parameter 'PartyMstId' of non-nullable type 'System.Int32' for method 'System.Web.Mvc.ActionResult EditPatymaster(Int32)' in 'WebParty.Controllers.PartyMstsController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter.
Parameter name: parameters
PartyMstsController(MVC PROJECT)
- namespace WebParty.Controllers{public class PartyMstsController : Controller
- {
- POLISHSTOCK_SJDMSEntities poly = new POLISHSTOCK_SJDMSEntities();
- public ActionResult EditPatymaster(int PartyMstId)
- {
- var std = poly.PartyMsts.Find(PartyMstId);
- return View(std);
- }
- [HttpPost]
- public JsonResult EditPatymaster(PartyMst partymst, int PartyMstId)
- {
- var partymstupdate = poly.PartyMsts.Find(PartyMstId);
- partymstupdate.PartyCode = partymst.PartyCode;
- partymstupdate.PartyName = partymst.PartyName;
- partymstupdate.Address = partymst.Address;
- partymstupdate.PhNo1 = partymst.PhNo1;
- partymstupdate.PhNo2 = partymst.PhNo2;
- partymstupdate.LogID = partymst.LogID;
- partymstupdate.PCID = partymst.PCID;
- partymstupdate.Ever = partymst.Ever;
- partymstupdate.SDate = partymst.SDate;
- partymstupdate.CompanyCode = partymst.CompanyCode;
- partymstupdate.PartyGroupCode = partymst.PartyGroupCode;
- partymstupdate.FixCode = partymst.FixCode;
- partymstupdate.OpBal = partymst.OpBal;
- partymstupdate.DivisionCode = partymst.DivisionCode;
- partymstupdate.PartyDate = partymst.PartyDate;
- partymstupdate.RDType = partymst.RDType;
- partymstupdate.Exchange = partymst.Exchange;
- partymstupdate.OpBalDollar = partymst.OpBalDollar;
- HttpResponseMessage response = staticvariable.client.PutAsJsonAsync("PartyMsts", partymst).Result;
- //entities.SaveChanges();
- return Json("your record update", JsonRequestBehavior.AllowGet);
- }
- }
- }
PartyMstsController(api project)
- namespace PartyCrops.Controllers
- {
- public class PartyMstsController : ApiController
- {
- private POLISHSTOCK_SJDMSEntities db = new POLISHSTOCK_SJDMSEntities();
- // PUT: api/PartyMsts/5
- [ResponseType(typeof(void))]
- public IHttpActionResult PutPartyMst(int id, PartyMst partyMst)
- {
- if (!ModelState.IsValid)
- {
- return BadRequest(ModelState);
- }
- if (id != partyMst.PartyMstId)
- {
- return BadRequest();
- }
- db.Entry(partyMst).State = EntityState.Modified;
- try
- {
- db.SaveChanges();
- }
- catch (DbUpdateConcurrencyException)
- {
- if (!PartyMstExists(id))
- {
- return NotFound();
- }
- else
- {
- throw;
- }
- }
- return StatusCode(HttpStatusCode.NoContent);
- }
- }
- }
Index.cshtml
- @Html.ActionLink("Edit", "EditPatymaster", new { id=item.PartyMstId }) |
- @model WebParty.Models.partymstmodel //here which model class include can u tell me(partymstmodel or partymst.cs (webapiproject->model->model1.edmx-> partymst.cs) ??????????????
- @{
- ViewBag.Title = "EditPatymaster";
- }
EditPatymaster
- namespace WebParty.Models
- {
- public class partymstmodel
- {
- public int PartyMstId { get; set; }
- public Nullable<int> PartyCode { get; set; }
- public string PartyName { get; set; }
- public string Address { get; set; }
- public string PhNo1 { get; set; }
- public string PhNo2 { get; set; }
- public Nullable<int> LogID { get; set; }
- public string PCID { get; set; }
- public Nullable<int> Ever { get; set; }
- public Nullable
SDate { get; set; } - public Nullable<int> CompanyCode { get; set; }
- public string PartyGroupCode { get; set; }
- public Nullable<int> FixCode { get; set; }
- public Nullable<decimal> OpBal { get; set; }
- public Nullable<int> DivisionCode { get; set; }
- public Nullable
PartyDate { get; set; } - public string RDType { get; set; }
- public Nullable<decimal> Exchange { get; set; }
- public Nullable<decimal> OpBalDollar { get; set; }
- }
- }
- //------------------------------------------------------------------------------
- //
- // This code was generated from a template.
- //
- // Manual changes to this file may cause unexpected behavior in your application.
- // Manual changes to this file will be overwritten if the code is regenerated.
- //
- //------------------------------------------------------------------------------
- namespace PartyCrops.Models
- {
- using System;
- using System.Collections.Generic;
- public partial class PartyMst
- {
- public int PartyMstId { get; set; }
- public Nullable<int> PartyCode { get; set; }
- public string PartyName { get; set; }
- public string Address { get; set; }
- public string PhNo1 { get; set; }
- public string PhNo2 { get; set; }
- public Nullable<int> LogID { get; set; }
- public string PCID { get; set; }
- public Nullable<int> Ever { get; set; }
- public Nullable
SDate { get; set; } - public Nullable<int> CompanyCode { get; set; }
- public string PartyGroupCode { get; set; }
- public Nullable<int> FixCode { get; set; }
- public Nullable<decimal> OpBal { get; set; }
- public Nullable<int> DivisionCode { get; set; }
- public Nullable
PartyDate { get; set; } - public string RDType { get; set; }
- public Nullable<decimal> Exchange { get; set; }
- public Nullable<decimal> OpBalDollar { get; set; }
- }
- }
Rahul PatilPosted Jan 11, 2020, 1:07 AM
Jignesh Kumar solve the issue.
Jignesh KumarPosted Jan 10, 2020, 11:03 PM
Rajanikant HawaldarPosted Jan 10, 2020, 9:43 PM
Rahul PatilPosted Jan 10, 2020, 8:48 AM
Rajanikant HawaldarPosted Jan 10, 2020, 8:25 AM