示例#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));
        }
示例#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));
        }
示例#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));
        }
示例#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));
        }
示例#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));
        }
示例#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));
        }
示例#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();
        }
示例#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));
        }