Exemple #1
0
 void checkIfDeadlineExceeded()
 {
     foreach (var item in _context.Offer.Where(w => DateTime.Now > w.EndDate).ToList())
     {
         item.DeadlineExceeded = true;
     }
     _context.SaveChanges();
 }
Exemple #2
0
        public Model.Address Insert(AddressInsertUpdateRequest request)
        {
            var entity = _mapper.Map <Address>(request);

            _context.Add(entity);
            _context.SaveChanges();

            return(_mapper.Map <Model.Address>(entity));
        }
Exemple #3
0
        public Model.Country Insert(CountryInsertUpdateRequest request)
        {
            var entity = _mapper.Map <Country>(request);

            _context.Add(entity);
            _context.SaveChanges();

            return(_mapper.Map <Model.Country>(entity));
        }
Exemple #4
0
        public Model.Worker Insert(WorkerInsertUpdateRequest request)
        {
            var entity = _mapper.Map <Worker>(request);

            _context.Add(entity);
            _context.SaveChanges();

            return(_mapper.Map <Model.Worker>(entity));
        }
Exemple #5
0
        public Model.ProjectTasks Insert(ProjectTasksInsertUpdateRequest t)
        {
            var entity = _mapper.Map <ProjectTasks>(t);

            _context.Add(entity);

            _context.SaveChanges();


            return(_mapper.Map <Model.ProjectTasks>(entity));
        }
Exemple #6
0
        public Model.Transaction Insert(TransactionInsertUpdateRequest t)
        {
            var entity = _mapper.Map <Transaction>(t);

            checkPaidAtribute(t.OfferId, t.Amount);
            _context.Add(entity);

            _context.SaveChanges();


            return(_mapper.Map <Model.Transaction>(entity));
        }
Exemple #7
0
        public async Task <IActionResult> Register(Model.Requests.RegisterRequest request)
        {
            if (request.Password == request.ConfirmPassword)
            {
                var userCheck = await _userManager.FindByEmailAsync(request.Email);

                if (userCheck != null)
                {
                    return(BadRequest("Email already exists"));
                }

                Address address = new Address
                {
                    CityId       = request.CityId.GetValueOrDefault(),
                    Name         = request.Address,
                    StreetNumber = request.StreetNumber
                };

                _context.Address.Add(address);
                _context.SaveChanges();

                var user = new AppUser
                {
                    AddressId         = address.AddressId,
                    BankAccountNumber = request.BankAccountNumber,
                    CompanyName       = request.CompanyName,
                    Email             = request.Email,
                    FirstName         = request.FirstName,
                    Iban        = request.Iban,
                    LastName    = request.LastName,
                    PhoneNumber = request.PhoneNumber,
                    Swift       = request.Swift,
                    UserName    = request.Email
                };

                var result = await _userManager.CreateAsync(user, request.Password);

                if (result.Succeeded)
                {
                    return(Ok());
                }
                else
                {
                    return(BadRequest(result.Errors));
                }
            }
            else
            {
                return(BadRequest("Password do not match"));
            }
        }