本文整理汇总了C#中NerdDinner.Models.Dinner类的典型用法代码示例。如果您正苦于以下问题:C# Dinner类的具体用法?C# Dinner怎么用?C# Dinner使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Dinner类属于NerdDinner.Models命名空间,在下文中一共展示了Dinner类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Create
public ActionResult Create()
{
Dinner dinner = new Dinner(){
EventDate=DateTime.Now.AddDays(7)
};
return View(new DinnerFormViewModel(dinner));
}
示例2: AddDeleteTest
public void AddDeleteTest()
{
var dinner = new Dinner()
{
Address = "address",
ContactPhone = "244-444-5555",
Country = "USA",
Description = "test dinner",
DinnerID = -1,
EventDate = DateTime.Now.AddDays(1),
HostedBy = "host",
Latitude = 1.222,
Longitude = 3.998,
Title = "Test Dinner"
};
repos.Add(dinner);
repos.Save();
Assert.AreEqual(12, repos.FindAllDinners().Count());
var result = repos.FindUpcomingDinners().ToList();
Assert.AreEqual("Test Dinner", result.ToArray()[0].Title);
repos.Delete(dinner);
repos.Save();
Assert.AreEqual(11, repos.FindAllDinners().Count());
}
示例3: Delete
public void Delete(Dinner dinner)
{
foreach (var rsvp in dinner.RSVPs) {
entities.RSVPs.DeleteObject(rsvp);
}
entities.Dinners.DeleteObject(dinner);
}
示例4: CreateTestDinners
public static List<Dinner> CreateTestDinners()
{
List<Dinner> dinners = new List<Dinner>();
for (int i = 1; i <= 100; i++)
{
Dinner sampleDinner = new Dinner()
{
Title = "Sample Dinner",
HostedBy = "SomeUser",
Address = "California",
Country = "USA",
ContactPhone = "425-555-1212",
Description = "Some description",
EventDate = DateTime.Now.AddDays(i),
Latitude = 99,
Longitude = -99
};
RSVP rsvp = new RSVP();
rsvp.AttendeeName = "SomeUser";
sampleDinner.AddRsvp(rsvp);
dinners.Add(sampleDinner);
}
return dinners;
}
示例5: CreateTestDinners
List<Dinner> CreateTestDinners()
{
List<Dinner> dinners = new List<Dinner>();
for (int i = 0; i < 101; i++)
{
Dinner sampleDinner = new Dinner()
{
DinnerID = i,
Title = "Sample Dinner",
HostedBy = "SomeUser",
Address = "Some Address",
Country = "USA",
EventDate = DateTime.Now.AddDays(i),
Latitude = 99,
Longitude = -99
};
dinners.Add(sampleDinner);
}
return dinners;
}
示例6: Create
public ActionResult Create(Dinner dinner)
{
if (ModelState.IsValid)
{
try
{
dinner.HostedBy = User.Identity.Name;
var rsvp = new RSVP();
rsvp.AttendeeName = User.Identity.Name;
dinner.RSVPs.Add(rsvp);
dinnerRepository.Add(dinner);
dinnerRepository.Save();
return RedirectToAction("Details", new {id = dinner.DinnerID});
}
catch
{
ModelState.AddModelErrors(dinner.GetRuleViolations());
}
}
return View(new DinnerFormViewModel(dinner));
}
示例7: CreateTestDinners
public static Tuple<List<Dinner>, List<Event>> CreateTestDinners()
{
List<Dinner> dinners = new List<Dinner>();
List<Event> events = new List<Event>();
for (int i = 1; i <= 101; i++)
{
Dinner sampleDinner = new Dinner()
{
DinnerID = i,
DinnerGuid = Guid.NewGuid(),
Title = "Sample Dinner",
HostedBy = "SomeUser",
Address = "Some Address",
Country = "USA",
ContactPhone = "425-555-1212",
Description = "Some description",
EventDate = DateTime.Now.AddDays(i),
Latitude = 99,
Longitude = -99
};
dinners.Add(sampleDinner);
var e = new Event();
e.Data = @"{""Name"":""SomeUser"",""FriendlyName"":""SomeUser""}";
e.EventType = "NerdDinner.Events.RSVPed";
e.DateTime = DateTime.UtcNow;
e.AggregateId = sampleDinner.DinnerGuid;
events.Add(e);
}
return Tuple.Create(dinners, events);
}
示例8: Index
public ActionResult Index(int dinnerCount = 100)
{
const string name = "Nerd";
var membershipService = new AccountMembershipService();
if(membershipService.ValidateUser(name, "password") == false) {
membershipService.CreateUser(name, "password", "[email protected]");
}
var repo = new DinnerRepository();
foreach(var d in repo.All) {
repo.Delete(d.DinnerID);
}
for (var i = 0; i < dinnerCount; i++) {
var dinner = new Dinner {Title = "Nerd-Out",
Description = "Nerding out with the nerds",
EventDate = DateTime.Now.Add(new TimeSpan(30, 0, 0, 0)),
ContactPhone = "403-999-9999",
Address = "Calgary, AB",
Country = "Canada",
HostedById = name,
HostedBy = name};
var rsvp = new RSVP {AttendeeNameId = name, AttendeeName = name};
dinner.RSVPs = new List<RSVP> {rsvp};
repo.InsertOrUpdate(dinner);
}
try {
repo.Save();
}
catch(DbEntityValidationException e) {
var error = e.EntityValidationErrors.First().ValidationErrors.First();
return new ContentResult {Content = string.Format("{0}: {1}", error.PropertyName, error.ErrorMessage)};
}
return new ContentResult{Content = "Success"};
}
示例9: Delete
public void Delete(Dinner dinner)
{
foreach (var rsvp in dinner.RSVPs)
{
_entities.RSVPs.Remove(rsvp);
}
_entities.Dinners.Remove(dinner);
}
示例10: Delete
public void Delete(Dinner dinner)
{
//foreach (RSVP rsvp in dinner.RSVPs.ToList())
// db.RSVPs.DeleteObject(rsvp);
//db.Dinners.DeleteObject(dinner);
var roi = new RiakObjectId(DinnerBucket, dinner.DinnerID);
_client.Delete(roi);
}
示例11: Add
public void Add(Dinner dinner)
{
EnsureTransaction();
if (!dinner.IsValid)
throw new ApplicationException("Rule violations prevent saving");
session.Save(dinner);
}
示例12: Save
public void Save(Dinner dinner)
{
if (!dinner.IsValid)
{
throw new ApplicationException("Rule violations");
}
_session.SaveOrUpdate(dinner);
}
示例13: Create
public ActionResult Create()
{
var dinner = new Dinner()
{
EventDate = DateTime.Now.AddDays(7),
HostedBy = User.Identity.Name
};
return View(dinner);
}
示例14: Create
public ActionResult Create(Dinner dinner)
{
if (ModelState.IsValid)
{
var command = new HostDinner(User.Identity.Name);
new HostDinnerCommandHandler().Handle(command, dinner, db);
return RedirectToAction("Index");
}
return View(dinner);
}
示例15: Create
public ActionResult Create(Dinner dinner)
{
if (ModelState.IsValid)
{
var command = new HostDinner(new DinnerId(dinner.DinnerID), User.Identity.Name, dinner.Title, dinner.EventDate, dinner.Description, dinner.ContactPhone, dinner.Address, dinner.Country);
new HostDinnerApplicationService(db).When(command);
return RedirectToAction("Index");
}
return View(dinner);
}