private bool CheckForNameAndNumberUniqueness(StyleViewModel svm) { // make sure the collection is valid if (svm.Style.Collection == null) { svm.Style.Collection = db.Collections.Find(svm.Style.CollectionId); } int iStyleNames = db.Styles. Join(db.Collections, s => s.CollectionId, col => col.Id, (s, c) => new { StyleId = s.Id, //StyleNum = s.StyleNum, StyleName = s.StyleName, CompanyId = c.CompanyId, }).Where(x => x.CompanyId == svm.CompanyId && x.StyleId != svm.Style.Id && (x.StyleName == svm.Style.StyleName)).Count(); if (iStyleNames != 0) { ModelState.AddModelError("Style.StyleName", "Style with this name already exists for " + db.FindCompany(svm.CompanyId).Name + "."); } if (iStyleNames != 0) { return(false); } return(true); }
public ActionResult Index(int?CompanyId) { if (CompanyId == null) { return(RedirectToAction("Index", "Home")); } Company company = db.FindCompany(CompanyId); if (company == null) { return(HttpNotFound()); } // Check for Labor Vendor LaborTableModel ltm = new LaborTableModel() { Labors = db.LaborTable.Where(l => l.CompanyId == CompanyId).ToList(), CompanyId = CompanyId.Value, CompanyName = company.Name, }; List <Vendor> vendors = db.Vendors.Where(v => v.CompanyId == CompanyId && (v.Type.Type & vendorTypeEnum.Labor) == vendorTypeEnum.Labor).ToList(); foreach (LaborItem li in ltm.Labors) { li.selectList = new SelectList(vendors, "Id", "Name", li.VendorId); } ltm.bHasVendors = vendors.Count != 0; return(View(ltm)); }
// GET: Clients public ActionResult Index(int?CompanyId) { if (CompanyId == null) { return(RedirectToAction("Index", "Home")); } Company co = db.FindCompany(CompanyId); if (co == null) { return(HttpNotFound()); } var clients = db.Clients.Where(c => c.CompanyID == CompanyId).Include(c => c.Company); ViewBag.CompanyId = CompanyId; ViewBag.CompanyName = co.Name; return(View(clients.ToList())); }
public ActionResult Create(int?companyId) { if (companyId == null) { return(RedirectToAction("Index", "Home")); } Company company = db.FindCompany(companyId); if (company == null) { return(RedirectToAction("Index", "Home")); } Vendor vendor = new Vendor(); VendorViewModel vvm = new VendorViewModel(vendor); vvm.CompanyName = company?.Name; vvm.CompanyId = companyId; return(View(vvm)); }
// GET: Stones/Create public ActionResult Create(int?companyId) { if (companyId == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Company company = db.FindCompany(companyId); ViewBag.CompanyId = companyId; ViewBag.ShapeId = new SelectList(db.Shapes.Where(s => s.CompanyId == companyId), "Id", "Name"); ViewBag.VendorId = new SelectList(db.Vendors.Where(v => v.CompanyId == companyId && ((v.Type.Type & vendorTypeEnum.Stone) == vendorTypeEnum.Stone)), "Id", "Name", company.defaultStoneVendor); ViewBag.CompanyName = db._Companies.Find(companyId)?.Name; Stone stone = new Stone { CompanyId = companyId, VendorId = company.defaultStoneVendor, Qty = 0 }; return(View(stone)); }
// GET: Findings/Create public ActionResult Create(int?companyId) { if (companyId == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Company company = db.FindCompany(companyId); if (company == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ViewBag.VendorId = new SelectList(db.Vendors.Where(v => v.CompanyId == companyId && ((v.Type.Type & vendorTypeEnum.Finding) == vendorTypeEnum.Finding)), "Id", "Name"); Finding finding = new Finding { CompanyId = companyId }; ViewBag.CompanyName = db._Companies.Find(companyId)?.Name; return(View(finding)); }
// GET: Markups public ActionResult Index(int?CompanyId) { if (CompanyId == null) { return(RedirectToAction("Index", "Home")); } Company company = db.FindCompany(CompanyId); if (company == null) { return(HttpNotFound()); } MarkupModel mm = new MarkupModel() { CompanyId = company.Id, CompanyName = company.Name }; if (company.markup != null) { mm.markups = JsonConvert.DeserializeObject <List <Markup> >(company.markup); } return(View(mm)); }
// GET: Presenters public ActionResult Index(int?companyId) { if (companyId == null) { return(RedirectToAction("Index", "Home")); } Company co = db.FindCompany(companyId); if (co == null) { return(HttpNotFound()); } var presenters = db.Presenters.Where(x => x.CompanyId == companyId).OrderBy(p => p.Name).Include(p => p.Company); foreach (Presenter p in presenters) { p.Phone = SetFormattedPhone(p.Phone); } ViewBag.CompanyName = co.Name; ViewBag.CompanyId = co.Id; return(View(presenters.ToList())); }
// GET: Collections public ActionResult Index(int?CompanyId) { if (CompanyId == null) { return(RedirectToAction("Index", "Home")); } Company co = db.FindCompany(CompanyId); List <Collection> collections = db.Collections.Include("Styles").Include("Styles.Memos").Where(c => c.CompanyId == co.Id).ToList(); if (co == null) { return(HttpNotFound()); } CollectionViewModel m = new CollectionViewModel(); m.CompanyId = co.Id; m.CompanyName = co.Name; m.Collections = new List <CollectionModel>(); foreach (Collection coll in collections.OrderBy(c => c.Name)) { CollectionModel collM = new CollectionModel() { Id = coll.Id, CompanyId = coll.CompanyId, Name = coll.Name }; collM.Styles = new List <StyleModel>(); foreach (Style sty in coll.Styles.OrderBy(s => s.StyleName).ThenBy(s => s.Desc)) { StyleModel styM = new StyleModel() { Id = sty.Id, Image = sty.Image, Desc = sty.Desc, Name = sty.StyleName, //Num = sty.StyleNum, Memod = sty.Memos.Sum(s => s.Quantity), Qty = sty.Quantity, RetialPrice = sty.RetailPrice ?? 0, // Cost is the sum of the component prices //Retail Price is the cost * retail ratio }; collM.Styles.Add(styM); } m.Collections.Add(collM); } return(View(m)); }