Beispiel #1
0
        public async Task <Registration> Create(Registration registration)
        {
            await _registrationRepository.Add(registration);

            await _registrationRepository.Commit();

            return(registration);
        }
Beispiel #2
0
        public RegistrationModel Add(int userId, int classId)
        {
            var item = registrationRepository.Add(userId, classId);

            return(new RegistrationModel
            {
                ClassId = item.ClassId,
            });
        }
Beispiel #3
0
        private static void PerformRegistration(SPWeb web, TrainingCourse course, SPUser user)
        {
            Registration registration = new Registration();

            registration.Title              = String.Format("{0} - {1}", course.Code, user.Name);
            registration.CourseId           = course.Id;
            registration.UserId             = user.ID;
            registration.RegistrationStatus = "Pending";

            IRegistrationRepository registrationRepository = ServiceLocator.GetInstance().Get <IRegistrationRepository>();

            registrationRepository.Add(registration, web);
        }
        public void Create(RegistrationDto registrationDto)
        {
            var student = _studentRepository.GetById(registrationDto.StudentId);
            var course  = _courseRepository.GetById(registrationDto.CourseId);

            RuleValidator.New()
            .When(course == null, Messages.INVALID_COURSE)
            .When(student == null, Messages.INVALID_STUDENT)
            .ThrowExceptionIfExists();

            var registration = new Registration(student, course, registrationDto.Value);

            _registrationRepository.Add(registration);
        }
Beispiel #5
0
        public async Task <bool> Add(Registration model)
        {
            var success = false;

            try
            {
                var entity = _registrationRepository.Add(model);
                await _unitOfWork.SaveChangesAsync();

                success = true;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(success);
        }
Beispiel #6
0
        public RegistrationDto Rsvp(NewAcceptanceMessage message)
        {
            var name = new Name {
                First = message.FirstName, Last = message.LastName
            };
            var registration = new Registration
            {
                Message = message.Message,
                Name    = name,
            };

            registration.Register();

            _registrationRepository.Add(registration);

            return(Mapper.Map <RegistrationDto>(registration));
        }
        public async Task <dynamic> Add(RegistrationRequest registrationRequest)
        {
            if (registrationRequest.StudentId == Guid.Empty)
            {
                AddError("StudentId is required");
                return(null);
            }

            if (registrationRequest.CoursetId == Guid.Empty)
            {
                AddError("CourseId is required");
                return(null);
            }

            _registrationRepository.Add(registrationRequest.StudentId, registrationRequest.CoursetId);

            return(await Task.FromResult(true));
        }
Beispiel #8
0
 public ActionResult Add(RegistrationViewModel viewModel)
 {
     if (ModelState.IsValid)
     {
         var registration = Mapper.Map <Registration>(viewModel);
         registration.DateTimeRequest = DateTime.Now;
         _registrationRepository.Add(registration);
         _registrationRepository.UnitOfWork.SaveChanges();
         return(PartialView(Mvc.View.Alerts.Alert, new BaseAlertViewModel {
             AlertType = AlertType.Success,
             CanClose = true,
             MessageCode = Dom.Translation.Registration.ApplicationAccepted
         }));
     }
     else
     {
         return(PartialView(Mvc.View.Registration.Add, viewModel));
     }
 }
Beispiel #9
0
 public tblRegistrationRequest PostRegistrant(tblRegistrationRequest item)
 {
     return(repository.Add(item));
 }
        public ActionResult NewRegistration(Registration model)
        {
            if (Convert.ToInt32(model.ViiiMm) > 0 && Convert.ToInt32(model.ViiiMo) == 0)
            {
                ModelState.AddModelError("ViiiMo", "Invalid marks provided.");
            }
            if (Convert.ToInt32(model.ViiiMo) > 0 && Convert.ToInt32(model.ViiiMm) == 0)
            {
                ModelState.AddModelError("ViiiMo", "Invalid marks provided.");
            }
            if (Convert.ToInt32(model.ViiiMm) > 0 && Convert.ToInt32(model.ViiiYear) < 1950)
            {
                ModelState.AddModelError("ViiiMo", "Invalid Year.");
            }

            if (Convert.ToInt32(model.Hsmm) > 0 && Convert.ToInt32(model.Hsmo) == 0)
            {
                ModelState.AddModelError("HsMo", "Invalid marks provided.");
            }
            if (Convert.ToInt32(model.Hsmo) > 0 && Convert.ToInt32(model.Hsmm) == 0)
            {
                ModelState.AddModelError("Hsmo", "Invalid marks provided.");
            }
            if (Convert.ToInt32(model.Hsmm) > 0 && Convert.ToInt32(model.Hsyear) < 1950)
            {
                ModelState.AddModelError("Hsmo", "Invalid Year.");
            }

            if (Convert.ToInt32(model.Immm) > 0 && Convert.ToInt32(model.Immo) == 0)
            {
                ModelState.AddModelError("Immo", "Invalid marks provided.");
            }
            if (Convert.ToInt32(model.ViiiMo) > 0 && Convert.ToInt32(model.ViiiMm) == 0)
            {
                ModelState.AddModelError("Immo", "Invalid marks provided.");
            }
            if (Convert.ToInt32(model.ViiiMm) > 0 && Convert.ToInt32(model.ViiiYear) < 1950)
            {
                ModelState.AddModelError("Immo", "Invalid Year.");
            }

            if (Convert.ToInt32(model.GrMm) > 0 && Convert.ToInt32(model.GrMo) == 0)
            {
                ModelState.AddModelError("GrMo", "Invalid marks provided.");
            }
            if (Convert.ToInt32(model.GrMo) > 0 && Convert.ToInt32(model.GrMm) == 0)
            {
                ModelState.AddModelError("GrMo", "Invalid marks provided.");
            }
            if (Convert.ToInt32(model.GrMm) > 0 && Convert.ToInt32(model.GrYear) < 1950)
            {
                ModelState.AddModelError("GrMo", "Invalid Year.");
            }

            if (Convert.ToInt32(model.PgMm) > 0 && Convert.ToInt32(model.PgMo) == 0)
            {
                ModelState.AddModelError("PgMo", "Invalid marks provided.");
            }
            if (Convert.ToInt32(model.PgMo) > 0 && Convert.ToInt32(model.PgMm) == 0)
            {
                ModelState.AddModelError("PgMo", "Invalid marks provided.");
            }
            if (Convert.ToInt32(model.PgMm) > 0 && Convert.ToInt32(model.PgYear) < 1950)
            {
                ModelState.AddModelError("PgMo", "Invalid Year.");
            }

            if (Convert.ToInt32(model.OtherMm) > 0 && Convert.ToInt32(model.OtherMo) == 0)
            {
                ModelState.AddModelError("OtherMo", "Invalid marks provided.");
            }
            if (Convert.ToInt32(model.OtherMo) > 0 && Convert.ToInt32(model.OtherMm) == 0)
            {
                ModelState.AddModelError("OtherMo", "Invalid marks provided.");
            }
            if (Convert.ToInt32(model.OtherMm) > 0 && Convert.ToInt32(model.OtherYear) < 1950)
            {
                ModelState.AddModelError("OtherMo", "Invalid Year.");
            }

            if (!ModelState.IsValid)
            {
                var _list = _districtRepository.GetAll();
                ViewBag.DistrictId  = new SelectList(_list, "DistrictId", "Name");
                ViewBag.DistrictId1 = new SelectList(_list, "DistrictId", "Name");
                ViewBag.DistrictId2 = new SelectList(_list, "DistrictId", "Name");
                ViewBag.DistrictId3 = new SelectList(_list, "DistrictId", "Name");
                ViewBag.DistrictId4 = new SelectList(_list, "DistrictId", "Name");
                ViewBag.DistrictId5 = new SelectList(_list, "DistrictId", "Name");

                var _blocks = _blockRepository.GetAll();
                if (model.DistrictId == 0)
                {
                    ViewBag.BlockId = new SelectList(null, "BlockId", "Name");
                }
                else
                {
                    ViewBag.BlockId = new SelectList(_blocks.Where(b => b.DistrictId == model.DistrictId), "BlockId", "Name");
                }

                var _posts = _postRepository.GetAll().OrderBy(c => c.Code).ThenBy(c => c.Name);
                ViewBag.PostId = new SelectList(_posts, "PostId", "Name");
                return(View(model));
            }

            var suffix = _registrationRepository.GetAll().Max(p => p.Suffix) + 1;

            model.Suffix            = suffix;
            model.Prefix            = "APEC";
            model.ApplicationNumber = "APEC" + suffix.ToString();
            model.RegDate           = DateTime.Today.Date;

            if (Convert.ToInt32(model.ViiiMo) > 0 && Convert.ToInt32(model.ViiiMm) > 0)
            {
                model.ViiiPer = Decimal.Round(Convert.ToDecimal((model.ViiiMo / model.ViiiMm) * 100), 2);
            }

            if (Convert.ToInt32(model.Hsmo) > 0 && Convert.ToInt32(model.Hsmm) > 0)
            {
                model.Hsper = Decimal.Round(Convert.ToDecimal((model.Hsmo / model.Hsmm) * 100), 2);
            }

            if (Convert.ToInt32(model.Immo) > 0 && Convert.ToInt32(model.Immm) > 0)
            {
                model.ImPer = Decimal.Round(Convert.ToDecimal((model.Immo / model.Immm) * 100), 2);
            }

            if (Convert.ToInt32(model.GrMo) > 0 && Convert.ToInt32(model.GrMm) > 0)
            {
                model.GrPer = Decimal.Round(Convert.ToDecimal((model.GrMo / model.GrMm) * 100), 2);
            }

            if (Convert.ToInt32(model.PgMo) > 0 && Convert.ToInt32(model.PgMm) > 0)
            {
                model.PgPer = Decimal.Round(Convert.ToDecimal((model.PgMo / model.PgMm) * 100), 2);
            }

            if (Convert.ToInt32(model.OtherMo) > 0 && Convert.ToInt32(model.OtherMm) > 0)
            {
                model.OtherPer = (model.OtherMo / model.OtherMm) * 100;
            }

            _registrationRepository.Add(model);
            unitOfWork.SaveChanges();
            return(View());
        }
Beispiel #11
0
        public IActionResult Post(RouteRegistrationDTO registrationDTO)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(Unauthorized());
            }

            var validation = _routeRegistrationDTOValidator.Validate(registrationDTO);

            if (!validation.IsValid)
            {
                return(BadRequest(validation));
            }

            string mailAdress = User.Identity.Name;

            if (mailAdress == null)
            {
                return(BadRequest());
            }

            var user = _userRepository.GetBy(mailAdress);

            if (user == null)
            {
                return(BadRequest());
            }

            var route = _routeRepository.GetBy(registrationDTO.RouteId);

            if (route == null)
            {
                return(NotFound("Chosen route could not be found."));
            }

            if (DateCheckHelper.CheckBeforeToday(route.Date))
            {
                return(BadRequest("You cannot register for a route in the past."));
            }

            var last = _registrationRepository.GetLast(mailAdress);

            if (last != null)
            {
                var lastRouteDate = _routeRepository.GetBy(last.RouteId).Date;
                if (DateCheckHelper.CheckAfterOrEqualsToday(lastRouteDate))
                {
                    return(BadRequest("You are already registered for a route this year."));
                }
            }

            var registration = registrationDTO.MapToRegistration(user, route);

            _registrationRepository.Add(registration, mailAdress);
            _userRepository.Update(user);

            var mailDTO = (user, route).MapToDTO();

            _mailService.SendRegistrationConfirmation(mailDTO);

            return(Ok(registration));
        }
Beispiel #12
0
        public async Task <ActionResult <RegistrationModel> > Post(RegistrationModel model)
        {
            try
            {
                var exist = await _repository.GetRegistrationByDate_TimeAsync(model.Day, model.TimeOfDay);

                if (exist != null)
                {
                    return(BadRequest("The registration in use"));
                }

                var url = _linkGenerator.GetPathByAction("Get",
                                                         "Registrations",
                                                         new { Day = model.Day, TimeOfDay = model.TimeOfDay });

                if (string.IsNullOrWhiteSpace(url))
                {
                    return(BadRequest("Could not use current Day and Time"));
                }

                Registration registration = _mapper.Map <Registration>(model);
                if (model.ClientId != 0)
                {
                    var client = _clientsRespository.GetById(model.ClientId);
                    if (client == null)
                    {
                        return(NotFound());
                    }

                    registration.Client = client;
                }
                if (model.HairdresserId != 0)
                {
                    var dresser = _hairdresserRepository.GetHairdresserById(model.HairdresserId);
                    if (dresser == null)
                    {
                        return(NotFound());
                    }
                    registration.Hairdresser = dresser;
                }
                if (model.SalonId != 0)
                {
                    var salon = await _salonRepository.GetSalonByIdAsync(model.SalonId);

                    if (salon == null)
                    {
                        return(NotFound());
                    }
                    registration.Salon = salon;
                }

                _repository.Add(registration);

                if (await _repository.SaveChangesAsync())
                {
                    return(Created(url, _mapper.Map <RegistrationModel>(registration)));
                }
                else
                {
                    return(BadRequest());
                }
            }
            catch (Exception ex)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, "Failed database"));
            }
        }