/// <summary> /// This is the class for Add party. /// </summary> /// <param name="partydata"></param> /// <returns></returns> public PartyresponseModel AddParty(Party partydata) { try { if (partydata != null) { return(partyRL.AddParty(partydata)); } else { return(null); } } catch (Exception) { throw; } }
public HttpResponseMessage Post([FromBody] Models.party oParty) { try { //bool save_user; 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.credit_limit.ToString())) { var format_type = RequestFormat.JsonFormaterString(); return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { output = "error", msg = "Credit Limit 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" })); } else { 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 insertParty = new Models.party { 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, region_id = oParty.region_id, territory_id = oParty.territory_id, credit_limit = oParty.credit_limit, city_id = oParty.city_id, created_by = oParty.created_by, created_date = DateTime.Now, dealer_type_id = oParty.dealer_type_id, retailer_type_id = oParty.retailer_type_id }; long insert_party = partyRepository.AddParty(insertParty); var formatter = RequestFormat.JsonFormaterString(); return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { output = "success", msg = "Information is saved successfully." }, formatter)); } } } catch (Exception ex) { var formatter = RequestFormat.JsonFormaterString(); return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { output = "error", msg = ex.ToString() }, formatter)); } }
public async Task AddParty(PartyViewModel party) { await _partyRepository.AddParty(PartyViewModel.ToDataModel(party)); }