public ActionResult Create([Bind(Include = "AssetLocationID,OrganizationBranchID,AssetLocationName,ShortName")] AssetLocation assetlocation) { if (ModelState.IsValid) { //db.AssetLocations.Add(assetlocation); //db.SaveChanges(); _assetLocationManager.Add(assetlocation); return(RedirectToAction("Index")); } var organizationBranchList = _organizationBranchManager.GetAll(); ViewBag.OrganizationBranchID = new SelectList(organizationBranchList, "OrganizationBranchID", "OrganizationBranchName"); return(View(assetlocation)); }
public ActionResult Create([Bind(Include = "Id,Name,ShortName,LocationCode,BranchId")] AssetLocation assetLocation) { if (ModelState.IsValid) { if (_assetLocationManager.IsShortNameUnique(assetLocation.ShortName)) { assetLocation.LocationCode = GetAssetLocationCode(assetLocation); _assetLocationManager.Add(assetLocation); return(RedirectToAction("Index")); } ModelState.AddModelError("ShortName", "ShortName is not Unique!"); } ViewBag.Organization = new SelectList(_organizationManager.GetAll(), "Id", "Name"); return(View(assetLocation)); }
public ActionResult Create(AssetLocation assetLocation) { if (assetLocationManager.IsExist(assetLocation.ShortName)) { ViewData["exist"] = "ShortName Already Exist"; //var dr =Request.Form["OrganizationId"]; } else { assetLocationManager.Add(assetLocation); ModelState.Clear(); return(RedirectToAction("Create", new { success = "true" })); } var list = organizationManager.GetAll(); ViewBag.orglist = list.ToList(); return(View(assetLocation)); }