Example #1
0
        public async Task CreateDiscount(DiscountViewModel viewModel)
        {
            var discount = _mapper.Map <Discount>(viewModel);

            _context.Add(discount);
            await _context.SaveChangesAsync();
        }
Example #2
0
        public async Task <Leave> CreateLeave(
            LeaveViewModel viewModel, ClaimsPrincipal user, HttpRequest request)
        {
            foreach (var file in request.Form.Files)
            {
                var memoryStream = new MemoryStream();
                file.CopyTo(memoryStream);
                viewModel.File     = memoryStream.ToArray();
                viewModel.FileName = file.FileName;
            }

            var leave    = _mapper.Map <Leave>(viewModel);
            var employee = await _context.Employees
                           .FirstOrDefaultAsync(e => e.UserId ==
                                                user.FindFirstValue(ClaimTypes.NameIdentifier)); //this is how we get the user Id

            leave.EmployeeId = employee.Id;

            leave.LeaveHistories.Add(new LeaveHistory
            {
                ApplicationDate = DateTime.Now,
                EmployeeId      = employee.Id
            });

            _context.Add(leave);
            await _context.SaveChangesAsync();

            return(leave);
        }
Example #3
0
        public async Task CreateDepartment(DepartmentViewModel viewModel)
        {
            var department = _mapper.Map <Department>(viewModel);

            _context.Add(department);
            await _context.SaveChangesAsync();
        }
Example #4
0
        public async Task CreateOfferItem(OfferItemViewModel viewModel)
        {
            var offerItem = _mapper.Map <OfferItem>(viewModel);

            _context.Add(offerItem);
            await _context.SaveChangesAsync();
        }
Example #5
0
        public async Task CreateOrder(OrderViewModel viewModel)
        {
            var order = _mapper.Map <Order>(viewModel);

            _context.Add(order);
            await _context.SaveChangesAsync();
        }
Example #6
0
        public async Task CreateInterview(InterviewViewModel viewModel)
        {
            var interview = _mapper.Map <Interview>(viewModel);

            _context.Add(interview);
            await _context.SaveChangesAsync();
        }
Example #7
0
        public async Task <Meeting> CreateMeeting(Meeting meeting)
        {
            var createMeeting = _context.Add(meeting);

            await _context.SaveChangesAsync();

            return(meeting);
        }
Example #8
0
        public async Task <Candidate> CreateCandidate(CandidateViewModel viewModel)
        {
            var candidate = _mapper.Map <Candidate>(viewModel);

            _context.Add(candidate);
            await _context.SaveChangesAsync();

            return(candidate);
        }
Example #9
0
        public async Task CreateSupplier(SupplierViewModel viewModel)
        {
            var supplier = _mapper.Map <Supplier>(viewModel);

            _context.Add(supplier);
            await _context.SaveChangesAsync();

            await CreateSupplierEmail(viewModel, supplier.Id);
            await CreateSupplierPhone(viewModel, supplier.Id);
            await CreateSupplierAddress(viewModel, supplier.Id);
        }
Example #10
0
        public async Task <Employee> CreateEmployee(EmployeeViewModel viewModel)
        {
            var user = new IdentityUser
            {
                UserName = viewModel.UserName,
                Email    = viewModel.Email
            };

            await _userManager.CreateAsync(user, viewModel.Password);

            var employee = _mapper.Map <Employee>(viewModel);

            employee.UserId = user.Id;
            _context.Add(employee);
            await _context.SaveChangesAsync();

            return(employee);
        }