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