public void save(BranchBuilding BranchBuilding) { try { using (var context = new SmsMisDB()) { BranchBuilding.AddDateTime = DateTime.Now; var entry = context.Entry(BranchBuilding); if (entry != null) { if (BranchBuilding.BuildingCode == 0) { BranchBuilding.BuildingCode = Functions.getNextPk("BranchBuilding", BranchBuilding.BuildingCode, BranchBuilding.CompanyCode, BranchBuilding.BranchCode); entry.State = EntityState.Added; } else { entry.State = EntityState.Modified; } context.SaveChanges(); } } } catch (System.Data.Entity.Validation.DbEntityValidationException ex) { throw ex; } catch (Exception ex) { throw ex; } }
public void deleteBranchBuilding(BranchBuilding BranchBuilding) { try { new hdlBranchBuilding().delete(BranchBuilding); } catch (Exception ex) { Response.StatusCode = 500; Content(JsonConvert.SerializeObject(new { error = ex.Message })); } //return getAllBranchBuilding(); }
public void saveBranchBuilding(BranchBuilding BranchBuilding) { try { BranchBuilding.AddByUserId = Convert.ToString(Session["User"]); new hdlBranchBuilding().save(BranchBuilding); } catch (Exception ex) { Response.StatusCode = 500; Content(JsonConvert.SerializeObject(new { error = ex.Message })); } //return getAllBranchBuilding(); }
public void delete(BranchBuilding BranchBuilding) { try { var context = new SmsMisDB(); context.BranchBuilding.Attach(BranchBuilding); var entry = context.Entry(BranchBuilding); if (entry != null) { entry.State = EntityState.Deleted; context.SaveChanges(); } } catch (System.Data.Entity.Validation.DbEntityValidationException ex) { //throw SmsMis.Models.Console.Common.ExceptionTranslater.translate(ex); throw ex; } catch (Exception ex) { //throw SmsMis.Models.Console.Common.ExceptionTranslater.translate(ex); throw ex; } }