Example #1
0
        public ActionResult Create([Bind(Include = "Id,FirstName,LastName,Address,Address2,City,State,ZipCode,Latitude,Longitude,PhoneNumber1,PhoneNumber2,EmailAddress,LastModifiedBy,LastModifiedDateTime,Name")] Tech model)
        {
            if (ModelState.IsValid)
            {
                ApplicationUser user = new ApplicationUser {
                    UserName = model.EmailAddress, Email = model.EmailAddress, FirstName = model.FirstName, LastName = model.LastName, IsConfirmed = true
                };
                ApplicationDbContext.SCreateUser(user, "cfi12345", "Tech");
                model.UserId = user.Id;

                model.LastModifiedById     = User.Identity.GetUserId();
                model.LastModifiedDateTime = DateTime.Now;
                try
                {
                    model.PhoneNumber1 = PhoneNumber10.Reformat(model.PhoneNumber1);
                    model.PhoneNumber2 = PhoneNumber10.Reformat(model.PhoneNumber2);
                    db.Teches.Add(model);
                    db.SaveChanges();
                }
                catch (DbEntityValidationException ex)
                {
                }
                return(RedirectToAction("Edit2", "Tech", new { id = model.UserId }));
            }

            return(View(model));
        }
Example #2
0
        public ActionResult Create([Bind(Include = "Id,Name,Active,ShowCloset")] Room room)
        {
            if (ModelState.IsValid)
            {
                db.Rooms.Add(room);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(room));
        }
Example #3
0
        public ActionResult Create([Bind(Include = "Id,Name,ImageName,Logo,QBClass")] StoreType storetype)
        {
            if (ModelState.IsValid)
            {
                db.StoreTypes.Add(storetype);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(storetype));
        }
        public ActionResult Create([Bind(Include = "Id,Description")] MaterialType materialtype)
        {
            if (ModelState.IsValid)
            {
                db.MaterialTypes.Add(materialtype);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(materialtype));
        }
Example #5
0
        public ActionResult Create([Bind(Include = "Id,Name,PrinterName,PrinterPort,PrinterDriver,Address,City,State,ZipCode,PhoneNumber,FaxNumber,ManagerId,Active,Latitude,Longitude,LabelPrinter")] Branch branch)
        {
            if (ModelState.IsValid)
            {
                db.Branches.Add(branch);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ManagerId = new SelectList(db.Employees, "Id", "FirstName", branch.ManagerId);
            return(View(branch));
        }
Example #6
0
        public ActionResult Create([Bind(Include = "ID,FirstName,LastName,CompanyName,Address,Address2,City,State,ZipCode,Latitude,Longitude,Directions,PhoneNumber1,PhoneNumber2,PhoneNumber3,EmailAddress,LastModifiedBy,LastModifiedDateTime,Name")] Customer customer)
        {
            if (ModelState.IsValid)
            {
                if (string.IsNullOrEmpty(customer.PhoneNumber1) && string.IsNullOrEmpty(customer.PhoneNumber2) && string.IsNullOrEmpty(customer.PhoneNumber3))
                {
                    return(View(customer));
                }
                customer.PhoneNumber1         = PhoneNumber10Ext.Reformat(customer.PhoneNumber1);
                customer.PhoneNumber2         = PhoneNumber10Ext.Reformat(customer.PhoneNumber2);
                customer.PhoneNumber2         = PhoneNumber10Ext.Reformat(customer.PhoneNumber2);
                customer.LastModifiedById     = User.Identity.GetUserId();
                customer.LastModifiedDateTime = DateTime.Now;
                db.Customers.Add(customer);
                int count = db.SaveChanges();
                return(RedirectToAction("Create", "Measure", new { id = customer.Id }));
            }

            return(View(customer));
        }
Example #7
0
        public ActionResult AddTech(Models.AddTech item)
        {
            if (ModelState.IsValid)
            {
                RandREng.MeasureDBEntity.Store store = db.Stores.Find(item.Id);
                RandREng.MeasureDBEntity.Tech  tech  = db.Teches.Find(item.TechId);
                if ((store == null || tech == null))
                {
                    return(HttpNotFound());
                }
                if (!store.Techs.Contains(tech))
                {
                    store.Techs.Add(tech);
                    db.Entry(store).State = EntityState.Modified;
                    int c = db.SaveChanges();
                }
                return(RedirectToAction("Details", "Store", new { id = item.Id }));
            }

            ViewBag.TechId = new SelectList(db.Teches, "Id", "Name", item.TechId);
            return(View(item));
        }
Example #8
0
 public ActionResult AddMaterial(AddMaterialModel model)
 {
     if (ModelState.IsValid)
     {
         Measure m = db.Measures.Find(model.MeasureId);
         if (m != null)
         {
             MeasureMaterial mm = new MeasureMaterial()
             {
                 MaterialTypeId     = model.MaterialTypeId.Value,
                 AltWidthId         = model.AltWidthId,
                 WidthId            = model.WidthId,
                 Description        = model.Description,
                 PatternMatchWidth  = model.PatternWidth,
                 PatternMatchLength = model.PatternLength
             };
             m.Materials.Add(mm);
             int c = db.SaveChanges();
             return(RedirectToAction("Details/" + model.MeasureId.ToString()));
         }
     }
     return(View(model));
 }