Ejemplo n.º 1
0
        public async Task <IActionResult> Confirmation([Bind("CustomerRegistrationId,WorkshopId,CustomerId")] CustomerRegistration customerRegistration)
        {
            var Registration = from R in _context.CustomerRegistration
                               where ((R.WorkshopId.Equals(customerRegistration.WorkshopId)) & (R.CustomerId.Equals(customerRegistration.CustomerId)))
                               select R;

            //we cheack that the specific customer is not registerd to the specific workshop
            if (!Registration.Any())
            {
                if (ModelState.IsValid)
                {
                    _context.Add(customerRegistration);
                    //update availabe members counter
                    var Workshop = from R in _context.Workshop.Include(w => w.Category).Include(w => w.Teacher)
                                   where (R.WorkshopId.Equals(customerRegistration.WorkshopId))
                                   select R;
                    Workshop.First().Available_Members = Workshop.First().Available_Members - 1;
                    _context.Workshop.Update(Workshop.First());

                    await _context.SaveChangesAsync();


                    //redirect to registration index
                    return(RedirectToAction(nameof(MyIndex)));
                }

                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                return(RedirectToAction("Error", "Home", new { message = "!לקוח יקר, הנך כבר רשום לסדנה זו" }));
            }
        }
        public async Task <IActionResult> Create([Bind("Id,Name,FullData,Price,Available_Members,Description,WorkshopCategory")] Workshop workshop)
        {
            if (ModelState.IsValid)
            {
                _context.Add(workshop);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(workshop));
        }
        public async Task <IActionResult> Create([Bind("Id,Name")] Category category)
        {
            if (ModelState.IsValid)
            {
                _context.Add(category);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(category));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> Create([Bind("Id,Name,Age,Email,PhoneNumber")] Customer customer)
        {
            if (ModelState.IsValid)
            {
                _context.Add(customer);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(customer));
        }
        public async Task <IActionResult> Create([Bind("Id")] Transaction transaction)
        {
            if (ModelState.IsValid)
            {
                _context.Add(transaction);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(transaction));
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> Create([Bind("WorkshopId,WorkshopName,CategoryId,FullData,Price,Available_Members,Description,TeacherId,Duration")] Workshop workshop)
        {
            if (ModelState.IsValid)
            {
                _context.Add(workshop);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CategoryId"] = new SelectList(_context.Category, "CategoryId", "CategoryName", workshop.CategoryId);
            ViewData["TeacherId"]  = new SelectList(_context.Teacher, "TeacherId", "TeacherName", workshop.TeacherId);
            return(View(workshop));
        }
Ejemplo n.º 7
0
        public async Task <IActionResult> Create([Bind("TeacherId,TeacherName")] Teacher teacher)
        {
            var Teacher = from R in _context.Teacher
                          where (R.TeacherName.Equals(teacher.TeacherName))
                          select R;

            if (!Teacher.Any())
            {
                if (ModelState.IsValid)
                {
                    _context.Add(teacher);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                }
                return(View(teacher));
            }
            else
            {
                return(RedirectToAction("Error", "Home", new { message = "מורה זה כבר רשום למערכת!" }));
            }
        }
Ejemplo n.º 8
0
        public async Task <IActionResult> Create([Bind("CategoryId,CategoryName")] Category category)
        {
            var Category = from R in _context.Category
                           where (R.CategoryName.Equals(category.CategoryName))
                           select R;

            if (!Category.Any())
            {
                if (ModelState.IsValid)
                {
                    _context.Add(category);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                }
                return(View(category));
            }
            else
            {
                return(RedirectToAction("Error", "Home", new { message = "!מורה יקר, קגוריה זו כבר קיימת" }));
            }
        }