public static string DeleteIncoterm(int incotermId) { EasyFreightEntities db = new EasyFreightEntities(); string isDeleted = "true"; IncotermLib countryToDel = db.IncotermLibs.Where(x => x.IncotermId == incotermId).FirstOrDefault(); db.IncotermLibs.Remove(countryToDel); try { db.SaveChanges(); } catch (Exception ex) { isDeleted = "false" + ex.Message; } return(isDeleted); }
public static string AddEditIncoterm(int incotermId, string incotermCode, string incotermName) { string isSaved = "true"; EasyFreightEntities db = new EasyFreightEntities(); IncotermLib incotermLibDb = new IncotermLib(); incotermLibDb.IncotermId = incotermId; incotermLibDb.IncotermCode = incotermCode; incotermLibDb.IncotermName = incotermName; if (string.IsNullOrEmpty(incotermName)) { return("false"); } if (incotermId == 0) { db.IncotermLibs.Add(incotermLibDb); } else { db.IncotermLibs.Attach(incotermLibDb); db.Entry(incotermLibDb).State = System.Data.Entity.EntityState.Modified; } try { db.SaveChanges(); } catch (Exception ex) { isSaved = "false" + ex.Message; } return(isSaved); }