//public StudentFixedDiscount SelectByIDs(int companyID) //{ // SmsMis.Models.Console.Handlers.Admin.SmsMisDB db = new SmsMis.Models.Console.Handlers.Admin.SmsMisDB(); // return db.Branch.ToList().Where(s => s.CompanyCode == companyID).ToList(); //} public void save(StudentFixedDiscount StudentFixedDiscount, string userId, bool isNew) { try { using (var context = new SmsMisDB()) { var entry = context.Entry(StudentFixedDiscount); if (entry != null) { StudentFixedDiscount.AddDateTime = DateTime.Now; StudentFixedDiscount.AddByUserId = userId; if (isNew) { entry.State = System.Data.Entity.EntityState.Added; } else { entry.State = System.Data.Entity.EntityState.Modified; } context.SaveChanges(); } } } catch (System.Data.Entity.Validation.DbEntityValidationException ex) { //throw ex; } catch (Exception ex) { // throw ex; } }
public ContentResult deleteStudentFixedDiscount(StudentFixedDiscount StudentFixedDiscount) { try { new hdlStudentFixedDiscount().delete(StudentFixedDiscount); } catch (Exception ex) { Response.StatusCode = 500; Content(JsonConvert.SerializeObject(new { error = ex.Message })); } return(getAllStudentFixedDiscount(StudentFixedDiscount.CompanyCode)); }
public ContentResult saveStudentFixedDiscount(StudentFixedDiscount StudentFixedDiscount, bool isNew) { try { new hdlStudentFixedDiscount().save(StudentFixedDiscount, Convert.ToString(Session["User"]), isNew); } catch (Exception ex) { Response.StatusCode = 500; Content(JsonConvert.SerializeObject(new { error = ex.Message })); } return(getAllStudentFixedDiscount(StudentFixedDiscount.CompanyCode)); }
public void delete(StudentFixedDiscount StudentFixedDiscount) { try { var context = new SmsMisDB(); context.StudentFixedDiscount.Attach(StudentFixedDiscount); var entry = context.Entry(StudentFixedDiscount); if (entry != null) { entry.State = System.Data.Entity.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; } }