1using System;2using System.Collections.Generic;3using System.ComponentModel.DataAnnotations;45namespace MyProject.WebAPI.Models
6{7 public class Tenant
8{9 public int TenantId { get; set;}10 public Guid TenantGUID { get; set;}11 public string Name { get; set;}12}1314}
###補足情報(言語/FW/ツール等のバージョンなど)
Microsoft Visual Studio Community 2017
Version 15.0.26228.9 D15RTWSVC
Microsoft .NET Framework
Version 4.6.01586
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Mvc;
using AdventureWorksLT;
namespace Mvc5App.Controllers
{
public class AddressesController : Controller
{
private AdventureWorksLTEntities db = new AdventureWorksLTEntities();
// GET: Addresses
public ActionResult Index()
{
return View(db.Address.ToList());
}
// GET: Addresses/Details/5
public ActionResult Details(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
Address address = db.Address.Find(id);
if (address == null)
{
return HttpNotFound();
}
return View(address);
}
// GET: Addresses/Create
public ActionResult Create()
{
return View();
}
// POST: Addresses/Create
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Create([Bind(Include = "AddressID,AddressLine1,AddressLine2,City,StateProvince,CountryRegion,PostalCode,rowguid,ModifiedDate")] Address address)
{
if (ModelState.IsValid)
{
db.Address.Add(address);
db.SaveChanges();
return RedirectToAction("Index");
}
return View(address);
}
// GET: Addresses/Edit/5
public ActionResult Edit(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
Address address = db.Address.Find(id);
if (address == null)
{
return HttpNotFound();
}
return View(address);
}
// POST: Addresses/Edit/5
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Edit([Bind(Include = "AddressID,AddressLine1,AddressLine2,City,StateProvince,CountryRegion,PostalCode,rowguid,ModifiedDate")] Address address)
{
if (ModelState.IsValid)
{
db.Entry(address).State = EntityState.Modified;
db.SaveChanges();
return RedirectToAction("Index");
}
return View(address);
}
// GET: Addresses/Delete/5
public ActionResult Delete(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
Address address = db.Address.Find(id);
if (address == null)
{
return HttpNotFound();
}
return View(address);
}
// POST: Addresses/Delete/5
[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public ActionResult DeleteConfirmed(int id)
{
Address address = db.Address.Find(id);
db.Address.Remove(address);
db.SaveChanges();
return RedirectToAction("Index");
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
db.Dispose();
}
base.Dispose(disposing);
}
}
}