public int Save(SETUP_Nationality newSetupNationality) { try { SCMSDataContext dbSCMS = Connection.Create(); SETUP_Nationality existingNationality = dbSCMS.SETUP_Nationalities.Where(c => c.Natn_Id.Equals(newSetupNationality.Natn_Id)).SingleOrDefault(); if (existingNationality != null) { existingNationality.Natn_Title = newSetupNationality.Natn_Title; existingNationality.Natn_Abbreviation = newSetupNationality.Natn_Abbreviation; existingNationality.Natn_Active = newSetupNationality.Natn_Active; existingNationality.Natn_SortOrder = newSetupNationality.Natn_SortOrder; } else { dbSCMS.SETUP_Nationalities.InsertOnSubmit(newSetupNationality); } dbSCMS.SubmitChanges(); return Convert.ToInt32(newSetupNationality.Natn_Id); } catch { return 0; } }
public ActionResult SaveRecord(string Code, string Title, string Abbreviation) { Int32 li_ReturnValue = 0; try { SETUP_Nationality row_Nationality = new SETUP_Nationality(); if (String.IsNullOrEmpty(Code)) { if (DALCommon.AutoCodeGeneration("SETUP_Nationality") == 1) { Code = DALCommon.GetMaximumCode("SETUP_Nationality"); } } if (!String.IsNullOrEmpty(Code)) { row_Nationality.Natn_Id = Code; row_Nationality.Natn_Code = Code; row_Nationality.Natn_Title = Title; row_Nationality.Natn_Abbreviation = Abbreviation; row_Nationality.Natn_Active = 1; row_Nationality.Natn_SortOrder = 1; li_ReturnValue = objDalNationality.Save(row_Nationality); ViewData["SaveResult"] = li_ReturnValue; } return PartialView("GridData"); } catch { return PartialView("GridData"); } }