Beispiel #1
0
        public async Task <IActionResult> Create(int guestReservationId, List <Gift> gifts)
        {
            if (ModelState.IsValid)
            {
                var allGifts = await _repository.GetGiftsByGuestReservationId(guestReservationId);

                foreach (var gift in allGifts)
                {
                    _repository.Delete <Gift>(gift);
                }
                await _repository.SavaAll();

                foreach (var gift in gifts)
                {
                    _repository.Add <Gift>(gift);
                }
                await _repository.SavaAll();

                var guest = await _repository.GetGuestReservation(guestReservationId);

                if (!await _repository.GetCheckGuidHaveWorkInTheDay(guest.MGuideId.Value, guest.ReservationDate))
                {
                    var contract = await _repository.GetGuideContractByGuideId(guest.MGuideId.Value);

                    var attend = new Attend()
                    {
                        GuideContractId = contract.Id,
                        TheWork         = "وجهاء",
                        WorkingHours    = contract.DailyWorkingHours,
                        GuideId         = guest.MGuideId.Value,
                        AttendDate      = guest.ReservationDate
                    };
                    _repository.Add <Attend>(attend);
                    await _repository.SavaAll();
                }
                return(RedirectToAction("NotablesByReservation", "Notables",
                                        new { guestReservationId = guestReservationId }).WithSuccess("success", "تم الحفظ بنجاخ"));
            }
            ViewData["ItemOfProducts"] = await _repository.GetItemOfProducts();

            ViewBag.guestReservationId = guestReservationId;
            var JobNotablesNormal = await _repository.GetJobNotablesNormal(guestReservationId);

            var JobNotablesNotNormal = await _repository.GetJobNotablesNotNormal(guestReservationId); await _repository.GetJobNotablesNormal(guestReservationId);

            ViewBag.notableNormal    = JobNotablesNormal.Count();
            ViewBag.notableNotNormal = JobNotablesNotNormal.Count();
            return(View(gifts));
        }
        public async Task <IActionResult> Create(GuidesAttendsCMV guidesAttendsCMV)
        {
            if (ModelState.IsValid)
            {
                var contract = await _repository.GetGuideContractByGuideId(guidesAttendsCMV.GuideId);

                var attend = new Attend()
                {
                    AppUserId       = int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value),
                    GuideContractId = contract.Id,
                    TheWork         = guidesAttendsCMV.TheWork,
                    WorkingHours    = contract.DailyWorkingHours,
                    GuideId         = guidesAttendsCMV.GuideId,
                    AttendDate      = guidesAttendsCMV.AttendDate
                };
                _repository.Add <Attend>(attend);
                await _repository.SavaAll();

                return(RedirectToAction(nameof(Index)).WithSuccess("success", "تم الحفظ بنجاح"));
            }
            ViewData["TheWork"]    = new SelectList(TheWorName(), "ThWork", "ThWork", guidesAttendsCMV.TheWork);
            ViewData["EmployeeId"] = new SelectList(await _repository.GetGuideContractActive(), "Id", "Name", guidesAttendsCMV.GuideId);
            return(View());
        }