Exemplo n.º 1
0
        public async Task <CreatedData> CreateAnimalAsync(AnimalDto animalDto)
        {
            var animalDbo = _mapper.Map <Animal>(animalDto);

            _dbContext.Animals.Add(animalDbo);

            await _dbContext.SaveChangesAsync();

            return(new CreatedData(animalDbo.AnimalId));
        }
Exemplo n.º 2
0
        public async Task <CreatedData> CreateEmployeeAsync(EmployeeDto employeeDto)
        {
            var employeeDbo = _mapper.Map <Employee>(employeeDto);

            _dbContext.Employees.Add(employeeDbo);

            await _dbContext.SaveChangesAsync();

            return(new CreatedData(employeeDbo.Id));
        }
Exemplo n.º 3
0
        public async Task <CreatedData> CreateAnimalDetailsAsync(AnimalDetailsDto model)
        {
            var detail = _mapper.Map <AnimalDetails>(model);

            _context.AnimalDetails.Add(detail);

            await _context.SaveChangesAsync();

            return(new CreatedData(detail.AnimalDetailsId));
        }
Exemplo n.º 4
0
        public async Task <CreatedData> CreateAnimalTypeAsync(string typeName)
        {
            var animalType = new AnimalType
            {
                TypeName = typeName
            };

            _context.AnimalTypes.Add(animalType);

            await _context.SaveChangesAsync();

            return(new CreatedData(animalType.AnimalTypeId));
        }
Exemplo n.º 5
0
        public async Task <CreatedData> CreateDeviceAsync(int animalId, string name, string deviceType)
        {
            var device = new SmartDevice
            {
                AnimalId   = animalId,
                Name       = name,
                DeviceType = _mapper.Map <DeviceType>(deviceType)
            };

            _context.SmartDevices.Add(device);
            await _context.SaveChangesAsync();

            return(new CreatedData(device.SmartDeviceId));
        }
Exemplo n.º 6
0
        public async Task <CreatedData> CreateJobAsync(string employeeId, string title, string description)
        {
            var jobDbo = new Job
            {
                EmployeeId   = employeeId,
                Title        = title,
                Description  = description,
                Status       = JobStatus.Created,
                CreationDate = DateTime.UtcNow
            };

            _dbContext.Jobs.Add(jobDbo);

            await _dbContext.SaveChangesAsync();

            return(new CreatedData(jobDbo.JobId));
        }
Exemplo n.º 7
0
        public async Task CreateZoo(ZooCreateViewModel model)
        {
            var newZoo = new Domain.Zoo()
            {
                Address = model.Address,
                Name    = model.Name,
                PicPath = model.PicPath
            };
            var result = await _context.AddAsync(newZoo);

            await _context.SaveChangesAsync();
        }
Exemplo n.º 8
0
        public async Task <CreatedData> CreateRecordAsync(int deviceId, string value, DateTime date)
        {
            var record = new DeviceRecord
            {
                SmartDeviceId = deviceId,
                Value         = value,
                Date          = date
            };

            _context.DeviceRecords.Add(record);
            await _context.SaveChangesAsync();

            return(new CreatedData(record.DeviceRecordId));
        }