//POST: api/record public bool Post([FromBody] Record record) { int maxID = db.Records.Max(r => r.RecordId); record.RecordId = ++maxID; try { _rep.Add(record); record.User = _user.GetById(record.UserId); record.Card = _card.GetById(record.CardId); record.Card.Pet = _pet.GetById(record.Card.PetId); record.Card.Pet.User = _user.GetById(record.Card.Pet.UserId); record.Service = _service.GetById(record.ServiceId); record.Time = _time.GetById(record.TimeId); //рассылка по почте EmailNotifier.IEmailNotifier mail = new EmailNotifier.MailRuNotifier("*****@*****.**", "*****@*****.**"); mail.Send("Заявка одобрена!", "Заявка номер " + record.RecordId + " для вашего питомца " + record.Card.Pet.Name + " одобрена.\n" + "Услуга " + record.Service.Name + ".\n" + "Цена услуги " + record.Service.Price + " рублей.\n" + "Время записи " + record.Time.Interval + ".", record.Card.Pet.User.Email.ToString()); return(true); } catch { return(false); } }
public void Add() { // Arrange var repository = new RecordRepository(); // Act var result = repository.Add(null); // Assert Assert.IsTrue(result); }
public async void Add() { var target = new RecordRepository(); var record = new Models.Record { Id = Guid.NewGuid().ToString(), Value = "This value was added programmatically!" }; await target.Add(record); var persistedRecord = await target.Get(record.Id); Assert.Equal(JsonConvert.SerializeObject(record), JsonConvert.SerializeObject(persistedRecord)); await target.Delete(record.Id); }
private void Add() { Console.Clear(); Record record = new Record(); record.TaskID = task.ID; record.UserID = AuthenticationService.LoggedUser.ID; Console.Write("Working Hours: "); record.WorkingHours = int.Parse(Console.ReadLine()); record.CreateDate = DateTime.Now; RecordRepository recordRepo = new RecordRepository(); recordRepo.Add(record); Console.WriteLine("Record successfully added!"); Console.ReadKey(true); }
public void GetAllIncludesAllRelationsOfRecord() { var brand = new Brand(); var model = new Model { Brand = brand }; var fuelType = new FuelType(); var engineType = new EngineType { Brand = brand }; var series = new Series { Brand = brand }; var doorType = new DoorType(); var category = new Category(); var country = new Country(); var exteriorColor = new ExteriorColor { Brand = brand }; var interiorColor = new InteriorColor { Brand = brand }; var person = new Person(); var driver = new Driver { Person = person }; var vehicle = new Vehicle { Brand = brand, Model = model, FuelType = fuelType, EngineType = engineType, Series = series, DoorType = doorType, Category = category, Country = country, ExteriorColor = exteriorColor, InteriorColor = interiorColor }; var fuelCard = new FuelCard { Driver = driver, Vehicle = vehicle }; var costAllocation = new CostAllocation(); var company = new Company(); var corporation = new Corporation { Company = company }; var record = new Record { FuelCard = fuelCard, CostAllocation = costAllocation, Corporation = corporation }; _sut.Add(record); var records = _sut.GetAll(); Assert.That(records, Is.Not.Null); var recordFromDatabase = records.FirstOrDefault(r => r.Id == record.Id); Assert.That(recordFromDatabase.CostAllocation, Is.EqualTo(costAllocation)); Assert.That(recordFromDatabase.Corporation, Is.EqualTo(corporation)); Assert.That(recordFromDatabase.Corporation.Company, Is.EqualTo(company)); Assert.That(recordFromDatabase.FuelCard.Vehicle.Brand, Is.EqualTo(brand)); Assert.That(recordFromDatabase.FuelCard.Vehicle.Model, Is.EqualTo(model)); Assert.That(recordFromDatabase.FuelCard.Vehicle.FuelType, Is.EqualTo(fuelType)); Assert.That(recordFromDatabase.FuelCard.Vehicle.EngineType, Is.EqualTo(engineType)); Assert.That(recordFromDatabase.FuelCard.Vehicle.Series, Is.EqualTo(series)); Assert.That(recordFromDatabase.FuelCard.Vehicle.DoorType, Is.EqualTo(doorType)); Assert.That(recordFromDatabase.FuelCard.Vehicle.Category, Is.EqualTo(category)); Assert.That(recordFromDatabase.FuelCard.Vehicle.Country, Is.EqualTo(country)); Assert.That(recordFromDatabase.FuelCard.Vehicle.ExteriorColor, Is.EqualTo(exteriorColor)); Assert.That(recordFromDatabase.FuelCard.Vehicle.InteriorColor, Is.EqualTo(interiorColor)); Assert.That(recordFromDatabase.FuelCard.Vehicle.FuelCard, Is.EqualTo(fuelCard)); Assert.That(recordFromDatabase.FuelCard.Driver, Is.EqualTo(driver)); Assert.That(recordFromDatabase.FuelCard.Driver.Person, Is.EqualTo(person)); }