// [Authorize(Roles = "Super Admin")] public JsonResult EditParty(tblParty objEditParty) { if (Session["role"] == null) { Session["userId"] = null; Session["role"] = null; return(Json(false, JsonRequestBehavior.AllowGet)); } else if (Session["role"].ToString() == "Super Admin") { return(Json(partyRepository.EditParty(objEditParty), JsonRequestBehavior.AllowGet)); } else { Session["userId"] = null; Session["role"] = null; return(Json(false, JsonRequestBehavior.AllowGet)); } }
public HttpResponseMessage Put([FromBody] Models.party oParty) { try { if (string.IsNullOrEmpty(oParty.party_name)) { var format_type = RequestFormat.JsonFormaterString(); return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { output = "error", msg = "Party Name can not be empty" })); } if (string.IsNullOrEmpty(oParty.address)) { var format_type = RequestFormat.JsonFormaterString(); return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { output = "error", msg = "Party Address can not be empty" })); } if (string.IsNullOrEmpty(oParty.mobile)) { var format_type = RequestFormat.JsonFormaterString(); return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { output = "error", msg = "Mobile No. can not be empty" })); } if (string.IsNullOrEmpty(oParty.party_type_id.ToString())) { var format_type = RequestFormat.JsonFormaterString(); return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { output = "error", msg = "Party Type can not be empty" })); } //if (partyRepository.CheckDuplicatePartyName(oParty.party_name)) //{ // var formatter = RequestFormat.JsonFormaterString(); // return Request.CreateResponse(HttpStatusCode.OK, new Confirmation { output = "error", msg = "Party Name Already Exists" }, formatter); //} else { Models.party updateParty = new Models.party { party_id = oParty.party_id, party_name = oParty.party_name, address = oParty.address, parent_party_id = oParty.parent_party_id, proprietor_name = oParty.proprietor_name, phone = oParty.phone, mobile = oParty.mobile, email = oParty.email, party_type_id = oParty.party_type_id, area_id = oParty.area_id, start_date = oParty.start_date, is_active = oParty.is_active, country_id = oParty.country_id, province_id = oParty.province_id, city_id = oParty.city_id, region_id = oParty.region_id, territory_id = oParty.territory_id, credit_limit = oParty.credit_limit, updated_by = oParty.updated_by, updated_date = DateTime.Now, dealer_type_id = oParty.dealer_type_id, retailer_type_id = oParty.retailer_type_id }; bool irepoUpdate = partyRepository.EditParty(updateParty); var formatter = RequestFormat.JsonFormaterString(); return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { output = "success", msg = "Information Updated Successfully" }, formatter)); } } catch (Exception ex) { var formatter = RequestFormat.JsonFormaterString(); return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { output = "error", msg = ex.ToString() }, formatter)); } }