Exemplo n.º 1
0
        public ActionResult Create(HttpPostedFileBase LeftFixedBkgrFile, HttpPostedFileBase RightFixedBkgrFile, HolidayModel holiday)
        {
            if (LeftFixedBkgrFile != null && LeftFixedBkgrFile.ContentLength > 0)
            {
                string fileName = Convert.ToInt32((DateTime.Now - new DateTime(2010, 01, 01)).TotalSeconds) + "_" + LeftFixedBkgrFile.FileName;
                string currentDomain = System.Configuration.ConfigurationManager.AppSettings["CurrentDomain"];
                string folder = "UploadedImages/backgroundimage";
                string filePath = System.Configuration.ConfigurationManager.AppSettings[currentDomain] + @"\" + folder + @"\" + fileName;

                using (new Impersonator("uploaduser", "", "Upload@@123"))
                {
                    LeftFixedBkgrFile.SaveAs(filePath);
                }
                holiday.LeftFixedBkgr = currentDomain + "/" + folder + "/" + fileName;
            }
            else
            {
                holiday.LeftFixedBkgr = "/Images/default-avatar.png";
            }

            if (RightFixedBkgrFile != null && RightFixedBkgrFile.ContentLength > 0)
            {
                string fileName = Convert.ToInt32((DateTime.Now - new DateTime(2010, 01, 01)).TotalSeconds) + "_" + RightFixedBkgrFile.FileName;
                string currentDomain = System.Configuration.ConfigurationManager.AppSettings["CurrentDomain"];
                string folder = "UploadedImages/backgroundimage";
                string filePath = System.Configuration.ConfigurationManager.AppSettings[currentDomain] + @"\" + folder + @"\" + fileName;

                using (new Impersonator("uploaduser", "", "Upload@@123"))
                {
                    RightFixedBkgrFile.SaveAs(filePath);
                }
                holiday.RightFixedBkgr = currentDomain + "/" + folder + "/" + fileName;
            }
            else
            {
                holiday.RightFixedBkgr = "/Images/default-avatar.png";
            }

            ModelState.Clear();
            TryValidateModel(holiday);

            if (ModelState.IsValid)
            {
                var holidayEn = AutoMapper.Mapper.Map<HolidayModel, Holiday>(holiday);
                _holidayRepository.InsertOrUpdate(holidayEn);
                _holidayRepository.Save();
                return RedirectToAction("Management");
            }
            return View(holiday);
        }
Exemplo n.º 2
0
        private void HolidayBooked(HolidayBookedEvent @event)
        {
            _holidayRepository.Save(@event.Source);

            var makeBookingCommand = new MakeBooking
            {
                Id            = @event.Source.Id.Value,
                EmployeeId    = @event.Source.Employee.Id.Value,
                Start         = @event.Source.Start,
                End           = @event.Source.End,
                BookingTypeId = Constants.HolidayBookingTypeId
            };

            _bus.Send(makeBookingCommand);
        }
Exemplo n.º 3
0
 public void HolidayBookedDomainEventHandler(HolidayBookedDomainEvent @event)
 {
     _holidayRepository.Save(@event.Source);
 }