Пример #1
0
        /// <summary>
        /// Method for adding new finance payment - RS
        /// </summary>
        /// <param name="currentUserInstituteId"></param>
        /// <param name="currentUser"></param>
        /// <param name="addedFinancePayment"></param>
        /// <returns></returns>
        public async Task <dynamic> AddNewFinancePaymentAsync(int currentUserInstituteId, ApplicationUser currentUser, FinancePayment addedFinancePayment)
        {
            if (await _imsDbContext.FinancePayments.AnyAsync(x => x.InstituteId == currentUserInstituteId && x.Code.ToLowerInvariant().Equals(addedFinancePayment.Code.ToLowerInvariant())))
            {
                return(new { Message = "Finance payment already exist with this code", HasError = true });
            }

            addedFinancePayment.CreatedBy   = currentUser.Id;
            addedFinancePayment.CreatedOn   = DateTime.UtcNow;
            addedFinancePayment.InstituteId = currentUserInstituteId;
            _imsDbContext.Add(addedFinancePayment);
            await _imsDbContext.SaveChangesAsync();

            return(new { Message = "Finance payment added successfully", HasError = false });
        }
        /// <summary>
        /// Method for adding new holiday
        /// </summary>
        /// <param name="newHoliday"></param>
        /// <returns></returns>
        public async Task AddNewHoliday(AddHolidayAc newHolidayAc, ApplicationUser currentUser)
        {
            int currentUserInstituteId = await _instituteUserMappingHelperService.GetUserCurrentSelectedInstituteIdAsync(currentUser.Id, true);

            Holiday newHoliday = new Holiday
            {
                AcademicYearId = newHolidayAc.AcademicYearId,
                HolidayDate    = newHolidayAc.FromDate,
                HolidayToDate  = newHolidayAc.ToDate,
                Description    = newHolidayAc.Description,
                OccuranceType  = newHolidayAc.OccuranceType,
                InstitutionId  = currentUserInstituteId,
                CreatedBy      = currentUser.Id,
                CreatedOn      = currentUser.CreatedOn
            };

            _imsDbContext.Add(newHoliday);
            await _imsDbContext.SaveChangesAsync();
        }