public async Task CreateDiscount(DiscountViewModel viewModel) { var discount = _mapper.Map <Discount>(viewModel); _context.Add(discount); await _context.SaveChangesAsync(); }
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); }
public async Task CreateDepartment(DepartmentViewModel viewModel) { var department = _mapper.Map <Department>(viewModel); _context.Add(department); await _context.SaveChangesAsync(); }
public async Task CreateOfferItem(OfferItemViewModel viewModel) { var offerItem = _mapper.Map <OfferItem>(viewModel); _context.Add(offerItem); await _context.SaveChangesAsync(); }
public async Task CreateOrder(OrderViewModel viewModel) { var order = _mapper.Map <Order>(viewModel); _context.Add(order); await _context.SaveChangesAsync(); }
public async Task CreateInterview(InterviewViewModel viewModel) { var interview = _mapper.Map <Interview>(viewModel); _context.Add(interview); await _context.SaveChangesAsync(); }
public async Task <Meeting> CreateMeeting(Meeting meeting) { var createMeeting = _context.Add(meeting); await _context.SaveChangesAsync(); return(meeting); }
public async Task <Candidate> CreateCandidate(CandidateViewModel viewModel) { var candidate = _mapper.Map <Candidate>(viewModel); _context.Add(candidate); await _context.SaveChangesAsync(); return(candidate); }
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); }
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); }