public string DeleteEntity(int entityId) { var result = dB_SPADevelopementEntities.Categories.Find(entityId); result.IsActive = 0; dB_SPADevelopementEntities.Entry(result).State = System.Data.Entity.EntityState.Modified; dB_SPADevelopementEntities.SaveChanges(); return("Category deleted successfully"); }
public string DeleteEntity(int entityId) { using (sMSDataLayerEntities) { var model = sMSDataLayerEntities.InstituteDetails.Find(entityId); sMSDataLayerEntities.Entry(model).State = System.Data.Entity.EntityState.Modified; sMSDataLayerEntities.SaveChanges(); return(SuccessErrorMessage.InstituteCreated); } }
public string DeleteEntity(int entityId) { var result = dB_SPADevelopementEntities.Classes.Find(entityId); result.IsActive = 0; result.UpdatedDate = DateTime.Now; dB_SPADevelopementEntities.Entry(result).State = System.Data.Entity.EntityState.Modified; dB_SPADevelopementEntities.SaveChanges(); return("Class Deleted successFully"); }
public string DeleteEntity(int entityId) { var result = dB_SPADevelopementEntities.Sections.Find(entityId); result.IsActive = 0; result.UpdatedBy = result.CreatedBy; result.CreatedDate = System.DateTime.Now; dB_SPADevelopementEntities.Entry(result).State = System.Data.Entity.EntityState.Modified; dB_SPADevelopementEntities.SaveChanges(); return("Section Master Deleted successfully"); }
public string DeleteEntity(int entityId) { using (dB_SPADevelopementEntities) { var result = dB_SPADevelopementEntities.AcademicMasters.Find(entityId); result.IsActive = 0; result.UpdateDate = DateTime.Now; result.UpdatedBy = result.CreatedBy; dB_SPADevelopementEntities.Entry(result).State = System.Data.Entity.EntityState.Modified; dB_SPADevelopementEntities.SaveChanges(); return("Academic master deleted successfully"); } }
public string AllocateStudentFee(List <int> stdIds, string[] headTypeId, string[] amounts, string [] discount, string [] discountPer, int [] paymentType) { using (var dB_SPADevelopementEntities = new DB_SPADevelopementEntities()) { for (int i = 0; i < stdIds.Count(); i++) { for (int j = 0; j < headTypeId.Count(); j++) { var allotedAmount = new FeeAmountBasedOnPaymentType().CalcullateFeeAmount(paymentType[j], string.IsNullOrEmpty(amounts[j]) ? 0 : decimal.Parse(amounts[j])); StudentFeeAllocation studentFeeAllocation = new StudentFeeAllocation(); studentFeeAllocation.StudentId = stdIds[i]; studentFeeAllocation.HeadTypeId = int.Parse(headTypeId[j]); studentFeeAllocation.AllotedAmount = allotedAmount; studentFeeAllocation.DiscountAmount = string.IsNullOrEmpty(discount[j])?0: decimal.Parse(discount[j]); studentFeeAllocation.DiscountPercentage = string.IsNullOrEmpty(discountPer[j])?0: decimal.Parse(discountPer[j]); // studentFeeAllocation.NetFeeAmount = new CalcullateNetAmount().GetCalcaullatedAmount(string.IsNullOrEmpty(discount[j])?0:decimal.Parse(discount[j]),string.IsNullOrEmpty(discountPer[j])?0: decimal.Parse(discountPer[j]),decimal.Parse(allotedAmount.ToString())); studentFeeAllocation.IsActive = 1; studentFeeAllocation.CreatedBy = 1; studentFeeAllocation.CreatedDate = DateTime.Now.Date; studentFeeAllocation.PaymentFeeType = Convert.ToInt32(paymentType[j]); dB_SPADevelopementEntities.StudentFeeAllocations.Add(studentFeeAllocation); dB_SPADevelopementEntities.SaveChanges(); } } return("Student fee allocation success"); } }
public void UpSertFeeAllocationMaster(FeeAllocationType feeAllocationType, string allocationOn, string[] HeadType, string[] amount, string[] discountPercenatge, string[] discountAmount, int [] paymentType) { var allocationList = (string.Join(",", allocationOn)).ConvertStringTolistInt <int>(); using (var dbContext = new DB_SPADevelopementEntities()) { var result = dbContext.StudentFeeAllocationMasters.Where(item => allocationList.Contains(item.AllocationTypeId)).ToList(); result.ForEach(item => { item.IsActive = 0; item.UpdatedBy = 1; item.UpDatedDate = DateTime.Now.Date; dbContext.Entry(item).State = System.Data.Entity.EntityState.Modified; dbContext.SaveChanges(); }); for (int i = 0; i < allocationOn.Count(); i++) { for (int j = 0; j < HeadType.Count(); j++) { StudentFeeAllocationMaster studentFeeAllocationMaster = new StudentFeeAllocationMaster(); studentFeeAllocationMaster.AllocationOn = Convert.ToInt32(allocationOn[i]); studentFeeAllocationMaster.AllocationTypeId = Convert.ToInt32(feeAllocationType); studentFeeAllocationMaster.HeadTypeId = Convert.ToInt32(HeadType[j]); studentFeeAllocationMaster.Amount = Convert.ToDecimal(amount[j]); studentFeeAllocationMaster.DiscountPercenatge = !string.IsNullOrEmpty(discountPercenatge[j])? Convert.ToDecimal(discountPercenatge[j]) :0; studentFeeAllocationMaster.DiscountAmount = !string.IsNullOrEmpty(discountAmount[j]) ? Convert.ToDecimal(discountAmount[j]) :0; studentFeeAllocationMaster.FeeType = Convert.ToInt32(paymentType[j]); studentFeeAllocationMaster.IsActive = 1; studentFeeAllocationMaster.CreatedBy = 1; dbContext.StudentFeeAllocationMasters.Add(studentFeeAllocationMaster); dbContext.SaveChanges(); } } } }
public void DeActiveFeeForStudent(List <int> id) { using (var dB_SPADevelopementEntities = new DB_SPADevelopementEntities()) { if (dB_SPADevelopementEntities.StudentFeeAllocations.Where(item => id.Contains(item.StudentId)).Count() > 0) { var result = dB_SPADevelopementEntities.StudentFeeAllocations.Where(item => id.Contains(item.StudentId)).ToList(); result.ForEach(item => { item.IsActive = 0; dB_SPADevelopementEntities.Entry(item).State = System.Data.Entity.EntityState.Modified; dB_SPADevelopementEntities.SaveChanges(); }); } } }
public string UpSertStudentMaster(StudentMasterVM studentMasterVM) { try { int studentId = 0; var result = ConvertSourceToDest <StudentMasterVM, Core.StudentMaster> .ConvertSourceToDestination(studentMasterVM); if (studentMasterVM.Id == 0) { using (dB_SPADevelopementEntities) { using (var transaction = dB_SPADevelopementEntities.Database.BeginTransaction()) { try { result.CreatedDate = DateTime.Now.Date; dB_SPADevelopementEntities.StudentMasters.Add(result); dB_SPADevelopementEntities.SaveChanges(); studentId = result.Id; StudentClassMapping studentClassMapping = new StudentClassMapping(); studentClassMapping.StudentId = studentId; studentClassMapping.AcademicYear = 1; studentClassMapping.classId = result.ClassId; studentClassMapping.sectionId = result.SectionId; studentClassMapping.CreatedBy = result.CreatedBy; studentClassMapping.CreatedDate = DateTime.Now.Date; dB_SPADevelopementEntities.StudentClassMappings.Add(studentClassMapping); dB_SPADevelopementEntities.SaveChanges(); transaction.Commit(); } catch (Exception ex) { transaction.Rollback(); } } } } //this code is used to perform the Student Master Update: else { using (dB_SPADevelopementEntities) { using (var transaction = dB_SPADevelopementEntities.Database.BeginTransaction()) { try { dB_SPADevelopementEntities.Entry(result).State = System.Data.Entity.EntityState.Modified; dB_SPADevelopementEntities.SaveChanges(); StudentClassMapping studentClassMapping = dB_SPADevelopementEntities.StudentClassMappings.Where(item => item.StudentId == result.Id).FirstOrDefault(); studentClassMapping.AcademicYear = studentMasterVM.AcademicYear; studentClassMapping.classId = studentMasterVM.ClassId; studentClassMapping.sectionId = studentMasterVM.SectionId; studentClassMapping.StudentId = result.Id; studentClassMapping.UpdatedBy = result.CreatedBy; studentClassMapping.UpdatedDate = DateTime.Now.Date; dB_SPADevelopementEntities.Entry(studentClassMapping).State = System.Data.Entity.EntityState.Modified; dB_SPADevelopementEntities.SaveChanges(); transaction.Commit(); } catch (Exception ex) { transaction.Rollback(); return(ex.Message); } } } } return("Student created successfully"); } catch (Exception e) { return(e.Message); } }