예제 #1
0
        public async Task <EmployeeDTO> CreateEmployee(EmployeeDTO employeeDTO)
        {
            Employee employee = ConvertDTOIntoEmployee(employeeDTO);

            _context.Entry(employee).State = EntityState.Added;
            await _context.SaveChangesAsync();

            employeeDTO.Id = employee.Id;

            return(employeeDTO);
        }
예제 #2
0
        public async Task <EquipmentItemDTO> Create(EquipmentItemDTO equipmentItem)
        {
            EquipmentItem entity = new EquipmentItem()
            {
                Name  = equipmentItem.Name,
                Value = equipmentItem.Value
            };

            _context.Entry(entity).State = EntityState.Added;
            await _context.SaveChangesAsync();

            equipmentItem.Id = entity.Id;

            return(equipmentItem);
        }
예제 #3
0
        public async Task <EmployeeEquipmentItemDTO> SetEquipmentItemAsBorrowedBy(int employeeId, EmployeeEquipmentItemDTO EEItemDTO)
        {
            if (!await CheckIfItemIsAvailable(EEItemDTO.EquipmentItemId))
            {
                //client is asking to borrow a piece of equipment not available, but there's no way of knowing that record's CKs
                return(null);
            }
            EEItemDTO.StatusId     = (int)EmployeeEquipmentStatus.Borrowed;
            EEItemDTO.DateBorrowed = DateTime.Now;
            EmployeeEquipmentItem EEItem = ConvertFromDTOtoEntity(EEItemDTO);

            EEItem.RecordStatusId        = (int)EmployeeEquipmentRecordStatus.Open;
            _context.Entry(EEItem).State = EntityState.Added;
            await _context.SaveChangesAsync();

            EEItemDTO.Status = ((EmployeeEquipmentStatus)EEItemDTO.StatusId).ToString();
            var EEItemDTOWithEquipmentItem = await AddEquipmentItem(EEItemDTO);

            return(EEItemDTOWithEquipmentItem);
        }