예제 #1
0
        public async Task <IActionResult> Create(Hobbie hobby)
        {
            _db.Hobbies.Add(hobby);
            await _db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
예제 #2
0
        public async Task <HobbieViewModel> addHobbie(HobbieViewModel model)
        {
            await addHobbieValidation(model);

            try
            {
                var hobbie = new Hobbie()
                {
                    userId = model.userId,
                    hobbie = model.hobbie
                };
                await db.AddAsync(hobbie);

                var result = (await db.SaveChangesAsync()) > 0;
                if (!result)
                {
                    throw new Exception("Add hobbie null");
                }
                return(new HobbieViewModel
                {
                    id = hobbie.id,
                    userId = hobbie.userId,
                    hobbie = hobbie.hobbie
                });
            }
            catch (Exception ex)
            {
                log.error("Delete hobbie error  - {0}", ex: ex, model);
                return(null);
            }
        }
예제 #3
0
        public async Task <IActionResult> Delete(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            Hobbie hobby = await _db.Hobbies.FindAsync(id);

            if (hobby == null)
            {
                return(NotFound());
            }
            return(View(hobby));
        }
예제 #4
0
    protected void OnDoneButtonClicked(object sender, EventArgs e)
    {
        string ty = Typebox.ActiveText;
        int    id = Locals.Count + 1;

        if (ty == "Cine")
        {
            Cine cine = new Cine(NameBox.Text, id, HoursBox.Text, OwnerBox.Text, ScreenSpin.ValueAsInt);
            LocalController.Locals.Add(cine);
        }

        else if (ty == "Hobbie")
        {
            Hobbie hobbie = new Hobbie(NameBox.Text, id, HoursBox.Text, OwnerBox.Text);
            LocalController.Locals.Add(hobbie);
        }
        else if (ty == "Restaurant")
        {
            Restaurant restaurant = new Restaurant(NameBox.Text, id, HoursBox.Text, OwnerBox.Text, ExTablesButton.Active);
            LocalController.Locals.Add(restaurant);
        }

        else if (ty == "Store")
        {
            string        cats = CatBox.Text;
            List <string> x    = new List <string>();
            foreach (string cat in cats.Split(','))
            {
                x.Add(cat);
            }
            Store store = new Store(NameBox.Text, id, HoursBox.Text, OwnerBox.Text, x);
            LocalController.Locals.Add(store);
        }

        int id2 = LocalController.Locals.Count;

        DoneLabel.Text = $"Local N˚ {id2} created!\n";
        Dictionary <int, Dictionary <string, string> > dict = LocalController.FillDict();
        string name  = $"Name: {dict[id2]["Name"]}\n";
        string owner = $"Owner: {dict[id2]["Owner"]}\n";
        string bh    = $"Business Hours: {dict[id2]["Business Hours"]}\n";

        DoneLabel.Text += name;
        DoneLabel.Text += owner;
        DoneLabel.Text += bh;
        DoneLabel.Show();
        Back();
    }
예제 #5
0
        public async Task <IActionResult> DeleteHobby(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            Hobbie hobby = await _db.Hobbies.FindAsync(id);

            if (hobby == null)
            {
                return(NotFound());
            }
            _db.Hobbies.Remove(hobby);
            await _db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
예제 #6
0
 public void Update(Hobbie entity)
 {
     _hobbieDAL.Update(entity);
 }
예제 #7
0
 public void Insert(Hobbie entity)
 {
     _hobbieDAL.Add(entity);
 }
예제 #8
0
 public void Delete(Hobbie entity)
 {
     _hobbieDAL.Delete(entity);
 }