Beispiel #1
0
        public JsonResult GetBoatBookings(double start, double end)
        {
            var fromDate = ConvertFromUnixTimestamp(start);
            var toDate   = ConvertFromUnixTimestamp(end);

            if (fromDate.Date < DateTime.Now.Date)
            {
                fromDate = DateTime.Now.Date;
            }
            BookingEntities context   = new BookingEntities();
            var             bookings  = context.GetBoatBookings(fromDate, toDate);
            var             eventList = from e in bookings
                                        select new
            {
                id          = e.Id,
                title       = e.boat + " Booked",
                description = "Booked By: " + e.MemberName,
                start       = e.BookingDate.ToString("s", System.Globalization.CultureInfo.InvariantCulture),
                //end = e.BookingDate.ToString("s", System.Globalization.CultureInfo.InvariantCulture),
                allDay          = true,
                member          = e.MemberName,
                backgroundColor = e.MemberName.ToLower() == WebSecurity.CurrentUserName.ToLower() ? "Green" : "Red"
            };
            var rows = eventList.ToArray();

            return(Json(rows, JsonRequestBehavior.AllowGet));
        }
Beispiel #2
0
 public bool DeleteBooking(string bookingId)
 {
     try
     {
         int                   bId = int.Parse(bookingId);
         BookingEntities       ctx = new BookingEntities();
         BoatBooking           b   = ctx.BoatBooking.Where(x => x.Id == bId).First();
         BookingCancelledModel cm  = new BookingCancelledModel
         {
             UserEmail        = b.Member.Email,
             UserName         = b.Member.Name,
             SailingClub      = ConfigurationManager.AppSettings["SailingClub"],
             Signature        = ConfigurationManager.AppSettings["Signature"],
             BookingReference = b.BookingMemberId.ToString() + "/" + b.Id.ToString(),
             BookingDate      = b.BookingDate
         };
         ctx.BoatBooking.Remove(b);
         ctx.SaveChanges();
         UserMailer     um  = new UserMailer();
         MvcMailMessage msg = um.BoatCancelledTreasurer(cm);
         msg.Send();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
        public int AddBooking(BookingEntities be)
        {
            var     config = new MapperConfiguration(cfg => cfg.CreateMap <BookingEntities, tblBooking>());
            IMapper mapper = config.CreateMapper();

            tblBooking ba        = mapper.Map <BookingEntities, tblBooking>(be);
            int        BookingId = bookingRepository.AddBooking(ba);

            return(BookingId);
        }
Beispiel #4
0
        public ActionResult Administrators()
        {
            BookingEntities           context = new BookingEntities();
            List <AdministratorModel> model   = new List <AdministratorModel>();
            var admins = context.GetAdministrators();

            foreach (var a in admins)
            {
                model.Add(new AdministratorModel
                {
                    Name  = a.Name,
                    Email = a.Email
                });
            }
            return(View(model));
        }
Beispiel #5
0
        public JsonResult GetBoats(string bookingDate)
        {
            BookingEntities context             = new BookingEntities();
            DateTime        bd                  = DateTime.Parse(bookingDate);
            List <BoatBookingListMember> bbList = new List <BoatBookingListMember>();
            var boats = context.GetavailableBoats(bd);

            foreach (Boat b in boats)
            {
                bbList.Add(new BoatBookingListMember
                {
                    Id   = b.Id,
                    Text = string.Format("{0} {1} {2}", b.Make, b.Class, b.Name)
                });
            }
            return(Json(bbList, JsonRequestBehavior.AllowGet));
        }
Beispiel #6
0
        //
        // GET: /Boat/
        public ActionResult Index()
        {
            BookingEntities context = new BookingEntities();
            Member          mbr     = (Member)context.Member.Where(m => m.UserProfileId == WebSecurity.CurrentUserId).First();
            Settings        set     = context.Settings.Find(1);
            int             CancelDays;

            if (!int.TryParse(ConfigurationManager.AppSettings["CancellationDays"], out CancelDays))
            {
                CancelDays = 1;
            }
            BoatBookingModel model = new BoatBookingModel
            {
                MemberName         = User.Identity.Name,
                CanBook            = mbr.CanBookBoats,
                AdvanceBookingDays = set.AdvanceDaysToBook,
                Title            = set.BookingPageHeader,
                Mesage           = set.BookingPageMessage,
                CancellationDays = CancelDays
            };

            return(View(model));
        }
Beispiel #7
0
        public IHttpActionResult Book(CommonBookingEntities objCommon, string Userid)
        {
            try
            {
                //Add Source Address To DB
                int _userId = Convert.ToInt32(Userid);
                var data    = db.UserRegistrations.Where(m => m.Id == _userId).FirstOrDefault();
                var company = db.CompanyDetails.Where(m => m.UserId == _userId).FirstOrDefault();

                SourceAddressEntities se = new SourceAddressEntities();
                se.CompanyName          = company.CompanyName;
                se.CreatedDate          = DateTime.Now;
                se.CustomerName         = data.Username;
                se.DocumentName         = objCommon.DocumentName;
                se.DocumentNumber       = objCommon.DocumentNumber;
                se.EmailId              = data.Email;
                se.IsActive             = true;
                se.Phone                = data.ContactNo;
                se.UserId               = data.Id;
                se.SourceAddress1       = objCommon.SourceAddress1;
                se.SourceAddress2       = objCommon.SourceAddress2;
                se.SourceCity           = objCommon.SourceCity;
                se.SourceState          = objCommon.SourceState;
                se.SourceCountry        = objCommon.SourceCountry;
                se.SourcePincode        = objCommon.SourcePincode;
                se.CreatedBy            = data.Id;
                se.SourceDocumentName   = objCommon.DestinationDocumentName;
                se.SourceDocumentNumber = objCommon.DestinationDocumentNumber;
                int SourceId = bookingManager.AddSourceAddress(se);

                //Add Destination Address To DB
                DestinationAddressEntities de = new DestinationAddressEntities();
                de.CompanyName         = objCommon.DestinationCompanyName;
                de.CreatedDate         = DateTime.Now;
                de.CustomerName        = data.Username;
                de.DocumentName        = objCommon.DestinationDocumentName;
                de.DocumentNumber      = objCommon.DestinationDocumentNumber;
                de.EmailId             = data.Email;
                de.IsActive            = true;
                de.Phone               = data.ContactNo;
                de.DestinationAddress1 = objCommon.DestinationAddress1;
                de.DestinationAddress2 = objCommon.DestinationAddress2;
                de.DestinationCity     = objCommon.DestinationCity;
                de.DestinationState    = objCommon.DestinationState;
                de.DestinationCountry  = objCommon.DestinationCountry;
                de.DestinationPincode  = objCommon.DestinationPincode;
                de.UpdatedDate         = DateTime.Now;
                de.UserId              = data.Id;
                de.DocumentName        = objCommon.DestinationDocumentName;
                de.DocumentNumber      = objCommon.DestinationDocumentNumber;

                int DestinationId = bookingManager.AddDestinationAddress(de);

                //Add Package Details To DB
                PackageEntities pe = new PackageEntities();
                pe.CreatedBy   = _userId;
                pe.Height      = objCommon.Height;
                pe.IsActive    = true;
                pe.Lenght      = objCommon.Lenght;
                pe.Packagename = objCommon.Packagename;
                pe.Quantity    = objCommon.Quantity;
                pe.UserId      = _userId;
                pe.Weight      = objCommon.Weight;
                pe.Width       = objCommon.Width;
                int PackageId = bookingManager.AddPackage(pe);


                //Get OfficeId


                string City = objCommon.SourceCity;
                int    OfficeId;
                int    oid          = db.Offices.Where(m => m.BranchLocation == City).Select(m => m.Id).First();
                int    OfficeUserId = db.Offices.Where(m => m.City == City).Select(m => m.UserId).FirstOrDefault();
                if (oid > 0)
                {
                    OfficeId = oid;
                }
                else
                {
                    OfficeId = 36;
                }
                //Add Booking Data To DB
                BookingEntities be = new BookingEntities();
                Helper          h1 = new Helper();
                be.Amount           = Convert.ToInt32(objCommon.Amount) / 100;
                be.CreatedBy        = _userId;
                be.CreatedDate      = DateTime.Now;
                be.DestinationId    = DestinationId;
                be.OfficeId         = OfficeId;
                be.PackageDetailsId = PackageId;
                be.PaymentType      = objCommon.PaymentType;
                be.ShipmentId       = h1.GetShipmentNumber();
                be.SourceId         = SourceId;
                be.UpdatedBy        = _userId;
                be.UpdatedDate      = DateTime.Now;
                be.Userid           = _userId;
                be.IsPickUp         = false;
                be.IsActive         = true;
                be.IsDelivered      = false;
                be.IsCurrent        = true;
                be.TransactionId    = objCommon.TransactionId;
                int BookingId = bookingManager.AddBooking(be);

                //Add Tracking Info in DB
                TrackingEntities te = new TrackingEntities();
                te.BookingId         = BookingId;
                te.CargoStatusTypeId = 1;
                te.CreatedBy         = _userId;
                te.CurrentLocation   = data.City;
                te.IsActive          = true;
                te.IsDelivered       = false;
                te.UpdatedBy         = OfficeUserId;
                te.IsCurrent         = true;
                int    TrackingId = bookingManager.AddTracking(te);
                string Message    = "Your Booking Is Done With Cargovio.in From " + se.SourceCity + " To " + de.DestinationCity + " With Shipment Id " + be.ShipmentId;
                sms.Send(data.ContactNo, Message);
                string AdminMessage = "You Receive One New Booking From" + se.SourceCity + " To " + de.DestinationCity + " With Shipment Id " + be.ShipmentId;
                sms.Send("9737920098", AdminMessage);
                var    data1         = db.UserRegistrations.Where(m => m.UserTypeId == 2 && m.OfficeId == OfficeId).FirstOrDefault();
                string CAdminMessage = "You Receive One New Booking From" + se.SourceCity + " To " + de.DestinationCity + " With Shipment Id " + be.ShipmentId;
                sms.Send(data1.ContactNo, CAdminMessage);
                return(Ok(TrackingId));
            }
            catch (Exception ex)
            {
                return(Ok(ex));
            }
        }
Beispiel #8
0
        public bool BookBoat(string bookingDate, string boatId)
        {
            BoatBooking     b   = null;
            BookingEntities ctx = null;;

            try
            {
                ctx = new BookingEntities();
                int      bId    = int.Parse(boatId);
                Member   booker = (Member)ctx.Member.Where(m => m.UserProfileId == WebSecurity.CurrentUserId).First();
                Boat     boat   = (Boat)ctx.Boat.Find(bId);
                DateTime bd     = DateTime.Parse(bookingDate);
                decimal  cost   = booker.Age < 18 ? 0.0m : boat.RentalCost;
                b = new BoatBooking
                {
                    BookingDate     = bd,
                    BoatId          = boat.Id,
                    BookingMemberId = booker.Id,
                    Units           = 1,
                    UnitCost        = cost,
                    TotalCost       = cost
                };
                ctx.BoatBooking.Add(b);
                ctx.SaveChanges();
                b = ctx.BoatBooking.Where((bb) => bb.BookingMemberId == b.BookingMemberId && bb.BookingDate == b.BookingDate && bb.BoatId == b.BoatId).First();
                BoatBookedModel mailModel = new BoatBookedModel
                {
                    BoatName         = boat.Make + " " + boat.Class + " " + boat.SailNumber,
                    BookingDate      = bd,
                    Cost             = cost,
                    UserEmail        = booker.Email,
                    UserName         = booker.Name,
                    SailingClub      = ConfigurationManager.AppSettings["SailingClub"],
                    Signature        = ConfigurationManager.AppSettings["Signature"],
                    BookingReference = b.BookingMemberId.ToString() + "/" + b.Id.ToString()
                };
                UserMailer     um           = new UserMailer();
                MvcMailMessage msgUser      = um.BoatBookedUser(mailModel);
                MvcMailMessage msgTreasurer = um.BoatBookedTreasurer(mailModel);
                msgUser.Send();
                msgTreasurer.Send();
                return(true);
            }
            catch
            {
                if (b != null && b.Id > 0)
                {
                    if (ctx != null)
                    {
                        ctx.BoatBooking.Remove(b);
                        ctx.SaveChanges();
                    }
                }
                return(false);
            }
            finally
            {
                if (ctx != null)
                {
                    ctx.Dispose();
                }
            }
        }