public JsonResult AddClient(Client objAddClient, string ClientIDHdn) { try { if (ClientIDHdn != null && ClientIDHdn != "") { int id = Convert.ToInt32(ClientIDHdn); cClient objClient = cClient.Get_ID(id); objClient.sName = objAddClient.ClientName; objClient.sEmailID = objAddClient.EmailIDUpdate; objClient.sContactNo = objAddClient.ContactUpdate; objClient.sAddress = objAddClient.Address; objClient.sDescription = objAddClient.Description; objClient.Save(); return(Json("2")); } else { cClient objClient = cClient.Create(); objClient.sName = objAddClient.ClientName; objClient.sEmailID = objAddClient.EmailID; objClient.sContactNo = objAddClient.Contact; objClient.sAddress = objAddClient.Address; objClient.sDescription = objAddClient.Description; objClient.Save(); return(Json("3")); } } catch (Exception ex) { throw ex; } }
/// <summary> /// Ensures that an object with the specified name exists, while creating other properties are set to their default values /// </summary> /// <param name="i_sName">Name</param> /// <returns>cClient object</returns> public static cClient CreateIfRequiredAndGet(string i_sName) { cClient oObj = cClient.Get_Name(i_sName); if (oObj == null) { oObj = cClient.Create(); oObj.sName = i_sName; oObj.Save(); } return(oObj); }