コード例 #1
0
        public ActionResult DeleteConfirmed(string id)
        {
            List <Production> products = db.Productions.OrderByDescending(p => p.ProductID).ToList();

            for (int i = 0; i < products.Count; i++)
            {
                string     text         = products[i].ProductID;
                Production productionid = db.Productions.OrderByDescending(q => q.ProductID == text).FirstOrDefault();
                db.Productions.Remove(productionid);
            }


            List <Manufacture> manufactures = db.Manufactures.OrderByDescending(r => r.ProductID).ToList();

            for (int i = 0; i < manufactures.Count; i++)
            {
                string      text          = manufactures[i].ProductID;
                Manufacture manufactureid = db.Manufactures.OrderByDescending(r => r.ProductID == text).FirstOrDefault();
                db.Manufactures.Remove(manufactureid);
            }

            Product product = db.Products.Find(id);

            db.Products.Remove(product);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #2
0
        public async Task <IActionResult> EditManufacture(Manufacture manufacture)
        {
            _DbContext.Manufactures.Update(manufacture);
            await _DbContext.SaveChangesAsync();

            return(RedirectToAction("ListManufacture"));
        }
コード例 #3
0
        protected ISmartHouse LoadSmartHouse()
        {
            ISmartHouse        sh       = null;
            SmartHouseConfig   shConfig = GetConfig();
            ISmartHouseCreator shc      = Manufacture.GetManufacture(modelAssembly);
            Type smartHouseType         = shc.SmartHouseType;

            if (smartHouseType.IsSubclassOf(typeof(DbContext)))
            {
                sh = shc.CreateSmartHouse();
            }
            else
            {
                if (shConfig.UseSession)
                {
                    var Session = HttpContext.Current.Session;
                    sh = Session["SmartHouse"] as ISmartHouse;
                }
                else
                {
                    sh = LoadFromStorage();
                }
            }
            return(sh);
        }
コード例 #4
0
        public void CreateProduct()
        {
            string modelName = "S-135-S0";
            int    modelYear = 2019;
            Model  model     = new Model
            {
                model_name = modelName,
                model_year = modelYear
            };

            Manufacture manufacturer = new Manufacture
            {
                ManufactureName = "BigAss Fans"
            };

            SubCategory subcategory = new SubCategory
            {
                SubCategoryName = "Electric"
            };

            // get manufacturer ID using Manufacturer Name
            //var manufacturerID = from manufacturer in Manufactures select manufacturer;


            Product product = new Product
            {
                ProductImgUrl = "https://ichef.bbci.co.uk/news/1024/cpsprodpb/151AB/production/_111434468_gettyimages-1143489763.jpg",
                ProductName   = "Fan 1",
                ModelID       = 1,
                ManufactureID = 1,
                SubCategoryID = 1,
            };
        }
コード例 #5
0
 private Manufacture CreateModel(ManufactureBindingModel model, Manufacture product)
 {
     product.ProductName = model.ProductName;
     product.Price       = model.Price;
     // удаляем убранные
     foreach (var key in product.ProductComponents.Keys.ToList())
     {
         if (!model.ProductComponents.ContainsKey(key))
         {
             product.ProductComponents.Remove(key);
         }
     }
     // обновляем существуюущие и добавляем новые
     foreach (var component in model.ProductComponents)
     {
         if (product.ProductComponents.ContainsKey(component.Key))
         {
             product.ProductComponents[component.Key] =
                 model.ProductComponents[component.Key].Item2;
         }
         else
         {
             product.ProductComponents.Add(component.Key,
                                           model.ProductComponents[component.Key].Item2);
         }
     }
     return(product);
 }
コード例 #6
0
        public void EditManufacturer()
        {
            string submit = "Update";

            Manufacture manufacturer = new Manufacture();

            {
                manufacturer.Manufacturer_Name = "Sony";
                manufacturer.Level             = 32;
            }

            mockManufacturerRepository.Setup(m => m.EditExistingManufacturer(manufacturer)).Returns(true);

            var manufacturerlist = new ManufacturerViewModels();

            {
                manufacturer.Manufacturer_Id   = 4;
                manufacturer.Manufacturer_Name = "Sony";
                manufacturer.Level             = 32;
            }
            manufacturerlist.Manufacturer = manufacturer;

            // Now invoke the Index action.
            var actionResult = manufacturercontroller.Index(submit, manufacturerlist, null);

            // Validate the expected result.
            ViewResult expectedResult = new ViewResult();

            Assert.IsNotNull(actionResult);
            //(branchList, (actionResult.Model as BranchViewModels).BranchList);
        }
コード例 #7
0
        public async Task <IActionResult> Edit(short id, [Bind("IdManufacture,Production,Quantity,Date,Employees")] Manufacture manufacture)
        {
            if (id != manufacture.IdManufacture)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    await Task.Run(() => manfacturerepo.Update(manufacture));
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ManufactureExists(manufacture.IdManufacture))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["Employees"]  = new SelectList(employeerepo.GetList(), "IdEmployees", "FullName", manufacture.Employees);
            ViewData["Production"] = new SelectList(finishedProductsrepo.GetList(), "IdFinishedProducts", "Names", manufacture.Production);
            return(View(manufacture));
        }
コード例 #8
0
        public ActionResult CreateDevice()
        {
            ViewBag.Title = title;

            SmartHouseContext  shContext  = LoadContext();
            ISmartHouseCreator devCreator = Manufacture.GetManufacture(modelAssembly);

            string devType = Request.Params[CreateDeviceFields.devType];

            string devName = Request.Params[CreateDeviceFields.name];

            if (devName == "" || devName == null)
            {
                devName = CreateDevicePlaceholders.name;
            }

            ISmartDevice dev = devCreator.CreateDevice(devType, devName);

            if (dev != null)
            {
                FillIHaveThermostat(dev);
                FillIBrightable(dev);

                shContext.SmartHouse.AddDevice(dev);
            }

            SmartHouseConfig shConfig = GetConfig();

            SaveSmartHouse(shContext.SmartHouse);

            return(View("Index", shContext as object));
        }
コード例 #9
0
ファイル: CarModel.cs プロジェクト: CyberMonster/Cyclamen
 public static CarModel FromCarDto(Car car, Manufacture manufacture, Model model)
 => new CarModel
 {
     Id = car.Id,
     ManufactureName = manufacture?.Name,
     ModelName       = model?.Name
 };
コード例 #10
0
ファイル: Default.aspx.cs プロジェクト: Mrak-IW/Asp-Dot-Net
        protected void Page_Load(object sender, EventArgs e)
        {
            ISmartHouseCreator shc = Manufacture.GetManufacture(modelAssembly);

            if (!IsPostBack)
            {
                CreateDeviceTypeDropDownList();
                Session["showAddDevice"] = null;
            }

            if (Session["SmartHouse"] == null)
            {
                ISmartDevice    dev;
                IBrightable     ibri;
                IHaveThermostat iterm;

                sh = shc.CreateSmartHouse();

                dev = shc.CreateDevice("SmartLamp", "l1");

                ibri = dev as IBrightable;
                ibri.BrightnessMax  = 100;
                ibri.BrightnessMin  = 10;
                ibri.BrightnessStep = 10;
                ibri.Brightness     = ibri.BrightnessMax;
                sh.AddDevice(dev);

                dev = shc.CreateDevice("SmartLamp", "l2");

                ibri = dev as IBrightable;
                ibri.BrightnessMax  = 100;
                ibri.BrightnessMin  = 10;
                ibri.BrightnessStep = 15;
                ibri.Brightness     = ibri.BrightnessMax;
                sh.AddDevice(dev);

                dev = shc.CreateDevice("Fridge", "fr1");

                iterm          = dev as IHaveThermostat;
                iterm.TempMax  = 0;
                iterm.TempMin  = -5;
                iterm.TempStep = 1;
                dev.On();
                iterm.DecreaseTemperature();
                sh.AddDevice(dev);

                dev = shc.CreateDevice("Clock", "clk1");

                dev.On();
                sh.AddDevice(dev);

                Session.Add("SmartHouse", sh);
            }
            else
            {
                sh = Session["SmartHouse"] as ISmartHouse;
            }

            RefreshControls();
        }
コード例 #11
0
        private ManufactureViewModel CreateModel(Manufacture product)
        {
            // требуется дополнительно получить список компонентов для изделия с названиями и их количество
            Dictionary <int, (string, int)> productComponents = new
                                                                Dictionary <int, (string, int)>();

            foreach (var pc in product.ProductComponents)
            {
                string componentName = string.Empty;
                foreach (var component in source.Components)
                {
                    if (pc.Key == component.Id)
                    {
                        componentName = component.ComponentName;
                        break;
                    }
                }
                productComponents.Add(pc.Key, (componentName, pc.Value));
            }
            return(new ManufactureViewModel
            {
                Id = product.Id,
                ProductName = product.ProductName,
                Price = product.Price,
                ProductComponents = productComponents
            });
        }
コード例 #12
0
        public Workshop(Manufacture wares, Stratum artisans, Treasury startup = null) : base(artisans)
        {
            Production = wares;
            if (startup is Treasury && startup != null)
            {
                Gold            = startup.Gold;
                Food            = startup.Food;
                Fuel            = startup.Fuel;
                SourceMaterials = startup.SourceMaterials;
            }
            switch (Production)
            {
            case Manufacture.Catridges:
                Cost             = CatridgeCost;
                ManDailyProgress = CatridgerPerManDay;
                break;

            case Manufacture.Weapon:
                Cost             = EquipmentCost;
                ManDailyProgress = EquipPerManDay;
                break;

            case Manufacture.None:
            default:
                throw new InvalidCastException("Что производит эта мастерская?");
            }
        }
コード例 #13
0
ファイル: IndiGear.cs プロジェクト: CScarame/PhoenixPt-Mods
 private static void AddItem(TacticalItemDef item)
 {
     Verbo("Unlock item: {0}", item.name);
     Manufacture.AddAvailableItem(item);
     PhoenixFaction.NewEntityKnowledge?["item"]?.Remove(item.Guid);
     UnlockCount++;
 }
コード例 #14
0
        public bool Save(Manufacture obj)
        {
            connect();
            SqlCommand cmd = new SqlCommand("[IUManufacture]", con);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@HospitalID", HospitalID);
            cmd.Parameters.AddWithValue("@LocationID", LocationID);
            if (obj.ManufactureID == 0)
            {
                cmd.Parameters.AddWithValue("@ManufactureID", 0);
                cmd.Parameters.AddWithValue("@Mode", "Add");
            }
            else
            {
                cmd.Parameters.AddWithValue("@ManufactureID", obj.ManufactureID);
                cmd.Parameters.AddWithValue("@Mode", "Edit");
            }
            cmd.Parameters.AddWithValue("@ManufactureName", obj.ManufactureName);

            cmd.Parameters.AddWithValue("@CreationID", UserID);
            con.Open();
            int i = cmd.ExecuteNonQuery();

            con.Close();
            if (i > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #15
0
    public void SetManufacture(Manufacture manufacture)
    {
        _manufacture = manufacture;

        _view.SetName(_manufacture.GetName());
        _view.SetDescription(_manufacture.GetDescription());
        _view.SetCost("Cost: " + _manufacture.GetCost());
    }
コード例 #16
0
        public ActionResult DeleteConfirmed(int id)
        {
            Manufacture manufacture = db.Manufactures.Find(id);

            db.Manufactures.Remove(manufacture);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #17
0
 public Tablet(Model model, Manufacture manufacture, Processores cpu, string motherboard, Storage gb, Os os, Color color, int qty, float price, Hardisk tb, camModels camModel, int pixels, float zoom, int f, float camPrice, double thic) : base(model, manufacture, cpu, motherboard, gb, os, color, qty, price, tb)
 {
     SetCamModel(camModel);
     SetPixels(pixels);
     SetZoom(zoom);
     SetF(f);
     SetCamPrice(camPrice);
     SetThic(thic);
 }
コード例 #18
0
        public static void UpdateManufacture(this Manufacture manufacture, ManufactureViewModel manufactureViewModel)
        {
            manufacture.ManufactureID   = manufactureViewModel.ManufactureID;
            manufacture.ManufactureName = manufactureViewModel.ManufactureName;

            manufacture.Description = manufactureViewModel.Description;
            manufacture.Logo        = manufactureViewModel.Logo;
            manufacture.Url         = manufactureViewModel.Url;
        }
コード例 #19
0
        private Manufacture AddManufacture(string make)
        {
            var manufacturer = new Manufacture()
            {
                ManufactureName = make
            };

            return(manufacturer);
        }
コード例 #20
0
        public List <Manufacture> GetFilterManufacturer(string searchColumn, string searchString, Guid userId)
        {
            List <Manufacture> qList = new List <Manufacture>();

            if (searchColumn == null)
            {
                searchColumn = "";
                searchString = "";
            }

            manufactureContext.Database.Initialize(force: false);

            var cmd = manufactureContext.Database.Connection.CreateCommand();

            cmd.CommandText = "[dbo].[USP_GetManufacturer]";
            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.Add(new SqlParameter("@SearchColumn", searchColumn));
            cmd.Parameters.Add(new SqlParameter("@SearchString", searchString));

            try
            {
                manufactureContext.Database.Connection.Open();
                // Run the sproc
                var reader = cmd.ExecuteReader();

                var result = ((IObjectContextAdapter)manufactureContext)
                             .ObjectContext
                             .Translate <Manufacture>(reader, "Manufacture", MergeOption.AppendOnly);


                foreach (var item in result)
                {
                    Manufacture model = new Manufacture()
                    {
                        Manufacturer_Id    = item.Manufacturer_Id,
                        Manufacturer_Name  = item.Manufacturer_Name,
                        Level              = item.Level,
                        IsActive           = item.IsActive,
                        Created_Branc_Id   = item.Created_Branc_Id,
                        Created_Dte        = item.Created_Dte,
                        Created_User_Id    = item.Created_User_Id,
                        Modified_Branch_Id = item.Modified_Branch_Id,
                        Modified_Dte       = item.Modified_Dte,
                        Modified_User_Id   = item.Modified_User_Id
                    };

                    qList.Add(model);
                }
            }
            finally
            {
                manufactureContext.Database.Connection.Close();
            }

            return(qList);
        }
コード例 #21
0
ファイル: GoodsManageService.cs プロジェクト: Mahdi2325/NCI
 public BaseResponse <Manufacture> SaveManufacture(Manufacture request)
 {
     if (string.IsNullOrEmpty(request.No))
     {
         request.OrgId = SecurityHelper.CurrentPrincipal.OrgId;
         request.No    = base.GenerateCode(SecurityHelper.CurrentPrincipal.OrgId, EnumCodeKey.ManufactureNo);
     }
     return(base.Save <LTC_MANUFACTURE, Manufacture>(request, (q) => q.Id == request.Id));
 }
コード例 #22
0
        public static Manufacture getManufacture(System.Data.Common.DbDataReader reader)
        {
            Manufacture manufacture = new Manufacture();

            manufacture.ManuName = reader.GetString(reader.GetOrdinal("ManuName"));
            manufacture.ManuURL  = reader.GetString(reader.GetOrdinal("ManuURL"));

            return(manufacture);
        }
コード例 #23
0
        public ActionResult AddManufacture(string manufactureName)
        {
            Manufacture manufacture = new Manufacture();

            manufacture.ManufactureName = manufactureName;
            db.Manufactures.Add(manufacture);
            db.SaveChanges();
            return(RedirectToAction("ShowManufactures"));
        }
コード例 #24
0
        public PartialViewResult ManufactureEdit(int id)
        {
            Manufacture manufacture = db.Manufactures.Find(id);

            ViewBag.StateID = new SelectList(db.States, "StateID", "StateName", manufacture.StateID);


            return(PartialView(manufacture));
        }
コード例 #25
0
 public ActionResult Edit([Bind(Include = "ManufactureId,FullName,ShortName,Detail")] Manufacture manufacture)
 {
     if (ModelState.IsValid)
     {
         db.Entry(manufacture).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(manufacture));
 }
コード例 #26
0
 public ActionResult Edit([Bind(Include = "ManufactureId,Name,Address,CodeAndCity,PhoneNumber,Nip")] Manufacture manufacture)
 {
     if (ModelState.IsValid)
     {
         db.Entry(manufacture).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(manufacture));
 }
コード例 #27
0
        public ActionResult Delete(int id)
        {
            Manufacture manufacture = db.Manufactures.Find(id);

            if (manufacture == null)
            {
                return(HttpNotFound());
            }
            return(View(manufacture));
        }
コード例 #28
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Manufacture user_Sec = new Manufacture
            {
                manufacture1 = it.Text.ToString(),
            };

            db.GetTable <Manufacture>().InsertOnSubmit(user_Sec);
            db.SubmitChanges();
        }
コード例 #29
0
        public ActionResult Create([Bind(Include = "ManufactureId,Name,Address,CodeAndCity,PhoneNumber,Nip")] Manufacture manufacture)
        {
            if (ModelState.IsValid)
            {
                db.Manufactures.Add(manufacture);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(manufacture));
        }
コード例 #30
0
        public ExpensiveManufacturer(Manufacture manufacture) : base()
        {
            this.id = manufacture.Id;

            // this.IsOrganisated = manufacture.IsOrganisated;
            this.OrganisationCost        = manufacture.OrganisationCost;
            this.ProbabilityOfOrganisate = manufacture.ProbabilityOfOrganisate;
            this.ProductionCapacity      = manufacture.ProductionCapacity;
            this.CapacityFree            = manufacture.ProductionCapacity;
            this.ClientsDeliveryCost     = manufacture.ClientsDeliveryCost;
        }