Exemplo n.º 1
0
        public ActionResult Create([Bind(Include = "ItemId,Name,Description,Price,Category,ItemPictureUrl,InternalImage,Visible")] Item item)
        {
            if (ModelState.IsValid)
            {
                db.Items.Add(item);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(item));
        }
Exemplo n.º 2
0
        public void SetAddress(int employeeId, string address)
        {
            var employee = context.Employees.Find(employeeId);

            if (employee == null)
            {
                throw new ArgumentException("Invalid ID!");
            }

            employee.Address = address;

            context.SaveChanges();
        }
Exemplo n.º 3
0
Arquivo: Program.cs Projeto: zmau/kaf
        private static void initDatabaseData()
        {
            PubContext dbContext = new PubContext();

            /*Role owner = new Role("administrator");
             * dbContext.Roles.Add(owner);
             * Role admin = new Role("menadžer");
             * dbContext.Roles.Add(admin);
             * Role employee = new Role("konobar");
             * dbContext.Roles.Add(employee);
             */
            dbContext.MeasureUnits.Add(new MeasureUnit()
            {
                name = "lit"
            });
            dbContext.MeasureUnits.Add(new MeasureUnit()
            {
                name = "kom"
            });
            dbContext.MeasureUnits.Add(new MeasureUnit()
            {
                name = "kg"
            });
            dbContext.MeasureUnits.Add(new MeasureUnit()
            {
                name = "dan"
            });
            dbContext.MeasureUnits.Add(new MeasureUnit()
            {
                name = "por"
            });

            dbContext.SaveChanges();
        }
        public void SetManager(int employeeId, int managerId)
        {
            var employee = this.context.Employees.Find(employeeId);

            var manager = this.context.Employees.Find(managerId);

            if (employee == null || manager == null)
            {
                throw new ArgumentException("Invalid ID!");
            }

            employee.Manager = manager;

            context.SaveChanges();
        }