Пример #1
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));
        }
Пример #2
0
        public Edit2ViewModels(RandREng.MeasureDBEntity.Tech tech)
        {
            this.Name         = tech.Name;
            this.Id           = tech.UserId;
            this.PhoneNumber1 = tech.PhoneNumber1;
            this.PhoneNumber2 = tech.PhoneNumber2;
            this.EmailAddress = tech.EmailAddress;

            this.Morning   = new int[7];
            this.Afternoon = new int[7];
            this.Evening   = new int[7];
            foreach (TechCapacity c in tech.Capacities)
            {
                switch (c.SlotType.Name)
                {
                case "Morning":
                    //if (c.DayOfWeek == 0)
                    //{
                    //	AM0 = c.Capacity;
                    //}
                    //if (c.DayOfWeek == 1)
                    //{
                    //	AM1 = c.Capacity;
                    //}
                    this.Morning[c.DayOfWeek] = c.Capacity;
                    break;

                case "Afternoon":
                    this.Afternoon[c.DayOfWeek] = c.Capacity;
                    break;

                case "Evening":
                    this.Evening[c.DayOfWeek] = c.Capacity;
                    break;
                }
            }
        }