public JsonResult deleteStudentFixedDiscountType(StudentFixedDiscountType StudentFixedDiscountType) { try { new hdlStudentFixedDiscountType().delete(StudentFixedDiscountType); } catch (Exception ex) { Response.StatusCode = 500; Content(JsonConvert.SerializeObject(new { error = ex.Message })); } return(getAllStudentFixedDiscountType(StudentFixedDiscountType.CompanyCode)); }
public JsonResult saveStudentFixedDiscountType(StudentFixedDiscountType StudentFixedDiscountType, bool isNew) { try { new hdlStudentFixedDiscountType().save(StudentFixedDiscountType, Convert.ToString(Session["User"]), isNew); } catch (Exception ex) { Response.StatusCode = 500; Content(JsonConvert.SerializeObject(new { error = ex.Message })); } return(getAllStudentFixedDiscountType(StudentFixedDiscountType.CompanyCode)); }
public void delete(StudentFixedDiscountType StudentFixedDiscountType) { try { var context = new SmsMisDB(); context.StudentFixedDiscountTypes.Attach(StudentFixedDiscountType); var entry = context.Entry(StudentFixedDiscountType); 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; } }
//public StudentFixedDiscountType 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(StudentFixedDiscountType StudentFixedDiscountType, string userId, bool isNew) { try { using (var context = new SmsMisDB()) { var entry = context.Entry(StudentFixedDiscountType); if (entry != null) { StudentFixedDiscountType.AddDateTime = DateTime.Now; StudentFixedDiscountType.AddByUserId = userId; if (isNew) { StudentFixedDiscountType.DiscountTypeCode = Functions.getNextPk("StudentFixedDiscountType", "DiscountTypeCode", string.Concat(" WHERE CompanyCode=", StudentFixedDiscountType.CompanyCode, " AND BranchCode=", StudentFixedDiscountType.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; } }