示例#1
0
        public async Task <int> FinishExaminationAsync(int applicationId)
        {
            var application = await _context.Applications.FindAsync(applicationId);

            application.Status       = EApplicationStatus.Examined;
            application.DateExamined = DateTime.Now;
            return(await _context.SaveChangesAsync());

            // TODO: send email or txt based on SaveChanges, message should contain if successful or has query
        }
        public async Task <SubmittedNameSearchResponseDto> CreateNewNameSearchAsync(Guid user,
                                                                                    NewNameSearchRequestDto dto)
        {
            var application =
                new Application(user, EService.NameSearch, EApplicationStatus.Submitted, dto.SortingOffice);
            var nameSearch = _mapper.Map <NewNameSearchRequestDto, Fridge.Models.Main.NameSearch>(dto);

            application.NameSearch = nameSearch;
            var transaction = await _context.Database.BeginTransactionAsync();

            try
            {
                await _context.AddAsync(application);

                await _context.SaveChangesAsync();

                application.NameSearch.Reference = $"NS/{nameSearch.NameSearchId}";

                Guid payment;
                try
                {
                    payment = await _paymentsService.BillAsync(EService.NameSearch, user, nameSearch.Reference);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    throw;
                }

                application.Payment = payment;
                await _context.SaveChangesAsync();

                await transaction.CommitAsync();
            }
            catch (Exception e)
            {
                await transaction.RollbackAsync();

                throw;
            }

            // TODO: verify if SaveChangesSuccessful
            return(new SubmittedNameSearchResponseDto
            {
                Id = application.ApplicationId,
                NameSearch = nameSearch.NameSearchId,
                Reference = nameSearch.Reference
            });
        }
示例#3
0
        public async Task <bool> addRegister(ClassRegister register)
        {
            context.Add(register);

            IQueryable <GymClasses> query = context.Classes;

            query = query.Where(p => p.ClassId == register.ClassIdForeignKey);

            GymClasses classToUpdate = query.FirstOrDefault();

            classToUpdate.CurrentStudents++;

            context.Update(classToUpdate);

            return((await context.SaveChangesAsync()) > 0);
        }
示例#4
0
        public async Task <int> AllocateTasksAsync(NewTaskAllocationRequestDto dto)
        {
            if (dto.ApplicationId > 0)
            {
                await AllocateSingleApplicationAsync(dto);
            }
            else
            {
                await AllocateMultipleApplicationsAsync(dto);
            }

            await _context.SaveChangesAsync();

            return(await _context.Applications.CountAsync(a =>
                                                          a.Service.Equals(dto.Service) && a.CityId.Equals(dto.SortingOffice) && a.TaskId.Equals(null)));
        }
        public async Task <int> ApprovePrivateEntityApplication(int applicationId)
        {
            var application = await _context.Applications.Include(a => a.RaisedQueries)
                              .SingleAsync(a => a.ApplicationId == applicationId && a.Status == EApplicationStatus.Examined);

            application.Status = EApplicationStatus.Approved;
            return(await _context.SaveChangesAsync());
        }
        public async Task AddImpression(CardImpression impression)
        {
            using (var context = new MainDatabaseContext())
            {
                await context.CardImpressions.AddAsync(impression);

                await context.SaveChangesAsync();
            }
        }
        public async Task <int> ChangeNameStatusAsync(int nameId, int status)
        {
            var name = await _context.Names.FindAsync(nameId);

            name.Status = (ENameStatus)status;

            if (status.Equals((int)ENameStatus.Reserved))
            {
                await _context.Entry(name).Reference(n => n.NameSearch).LoadAsync();

                await _context.Entry(name.NameSearch).Collection(n => n.Names).LoadAsync();

                var unconsideredNames = name.NameSearch.Names.Where(n =>
                                                                    !n.EntityNameId.Equals(name.EntityNameId) && n.Status.Equals(ENameStatus.Pending))
                                        .ToList();
                foreach (var unconsideredName in unconsideredNames)
                {
                    unconsideredName.Status = ENameStatus.NotConsidered;
                }
            }

            return(await _context.SaveChangesAsync());
        }
        public async Task <int> FinishApplicationAsync(Guid user, int applicationId)
        {
            var application = await GetPrivateEntityApplicationAsync(user, applicationId);

            application.PrivateEntity.Reference = "P/L: " + application.PrivateEntity.PrivateEntityId;


            Guid payment;

            try
            {
                payment = await _paymentsService.BillAsync(application.Service, application.User,
                                                           application.PrivateEntity.Reference);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }

            application.Payment = payment;
            application.Status  = EApplicationStatus.Submitted;
            return(await _context.SaveChangesAsync());
        }
示例#9
0
 public async Task <bool> addGym(Gym gym)
 {
     context.Add(gym);
     return((await context.SaveChangesAsync()) > 0);
 }
示例#10
0
 public async Task <bool> addRating(InstructorRating rating)
 {
     context.Add(rating);
     return((await context.SaveChangesAsync()) > 0);
 }
示例#11
0
 /*
  * Method Name:
  *  addUser
  * Purpose:
  *  This adds a user to the reset password table.
  */
 public async Task <bool> addUser(PasswordReset user)
 {
     context.Add(user);
     return((await context.SaveChangesAsync()) > 0);
 }
示例#12
0
 public async Task <bool> addApplication(GymApplications application)
 {
     context.Add(application);
     return((await context.SaveChangesAsync()) > 0);
 }
示例#13
0
 public async Task <bool> addClass(GymClasses gymClass)
 {
     context.Add(gymClass);
     return((await context.SaveChangesAsync()) > 0);
 }
示例#14
0
        public async Task <bool> addNewClassInstance(ClassAttendance classToGet)
        {
            context.Add(classToGet);

            return((await context.SaveChangesAsync()) > 0);
        }
示例#15
0
 public async Task <bool> addWeight(WeightData weight)
 {
     context.Add(weight);
     return((await context.SaveChangesAsync()) > 0);
 }
示例#16
0
 public async Task <bool> addAttendence(GymAttendanceRecord record)
 {
     context.Add(record);
     return((await context.SaveChangesAsync()) > 0);
 }
示例#17
0
 public async Task <bool> addList(GymMember[] memberList)
 {
     context.Add(memberList);
     return((await context.SaveChangesAsync()) > 0);
 }
示例#18
0
        /*
         * Method Name:
         *  addUser
         * Purpose:
         *  Adds a new user to the notification settings table.
         */
        public async Task <bool> addUser(NotificationSettings user)
        {
            context.Add(user);

            return((await context.SaveChangesAsync()) > 0);
        }
示例#19
0
 public async Task <bool> addAdmin(SupportUsers user)
 {
     context.Add(user);
     return((await context.SaveChangesAsync()) > 0);
 }