public ActionResult EditBook(FormCollection form, int id)
        {
            tblBooking book = dc.tblBookings.SingleOrDefault(ob => ob.ConsignmentId == id);

            book.VehicleId     = Convert.ToInt32(form["ddVehicle"]);
            book.DriverId      = Convert.ToInt32(form["ddDriver"]);
            book.DispatchDate  = Convert.ToDateTime(form["txtDispatch"]);
            book.DeliveredDate = Convert.ToDateTime(form["txtDeliver"]);
            book.TotalPayment  = Convert.ToInt32(form["txtPayment"]);
            book.PaymentMode   = form["txtPaymentMode"];
            book.Remarks       = form["txtRemark"];
            Session["Price"]   = book.TotalPayment;
            dc.SaveChanges();

            tblBidding bidding = dc.tblBiddings.SingleOrDefault(ob => ob.BidId == book.BidId);

            bidding.IsAssigned = true;
            dc.SaveChanges();

            tblConsignment con = dc.tblConsignments.SingleOrDefault(ob => ob.ConsignmentId == id);

            con.IsProcessed = true;
            dc.SaveChanges();

            return(RedirectToAction("bill", "ClientCompany", new { id = book.BookingId }));
        }
 public ActionResult booking1(tblBooking b1)       //values of booking are bought through b1 object
 {
     if (ModelState.IsValid)
     {
         tblLogin z = (tblLogin)Session["customerid"];
         string   n = z.UserId;
         if (n == b1.Customer_ID)
         {
             string s = Dbclass.Hotelbooking(b1);                             //validations and billamount is returned through this s
             if (s.StartsWith("N") || s.StartsWith("a") || s.StartsWith("H")) //if validations are not satisfied it goes to booking view and generate which validation is missing
             {
                 ViewBag.msg = s;
                 return(View("booking"));
             }
             else
             {
                 ViewBag.msg     = s;
                 Session["bill"] = s;
                 Session["var"]  = b1;                      //here we are storing object of tblbooking by using sessions so that we can use this value after payment
                 slist           = Dbclass.getstate();      //this slist consists values of bankdetails we will use it to populate dropdown values in payment view
                 ViewBag.bankid  = slist;
                 return(View("payment"));
             }
         }
         else
         {
             ViewBag.msg = "Please Enter Your CustomerId";
             return(View("booking"));
         }
     }
     return(View("booking"));
 }
Example #3
0
        public IHttpActionResult UpdateCancellation(string username, string bit)
        {
            /*if (!ModelState.IsValid)
             * {
             *  return BadRequest(ModelState);
             * }*/

            try
            {
                tblBooking newbooking = new tblBooking();
                newbooking = db.tblBookings.Find(username);
                if (newbooking != null)
                {
                    newbooking.CancellationBit = bit;

                    db.SaveChanges();
                }
                else
                {
                    return(NotFound());
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(Ok());
        }
        public ActionResult bookingupdate(int id)           //booking update can be done here
        {
            tblBooking t = Dbclass.getbookingdetails(id);   //which booking id we want to change that we are retrieving from database and populating in view

            Session["opp"] = t;                             //here by using session variable we are storing the object of that bookingid which we want to edit
            return(View(t));
        }
Example #5
0
        ///[ResponseType(typeof(tblBooking))]
        public IHttpActionResult UpdateCancellation(string paymentid)
        {
            /*if (!ModelState.IsValid)
             * {
             *  return BadRequest(ModelState);
             * }*/

            try
            {
                tblBooking newbooking = new tblBooking();
                //newbooking = db.tblBookings.Find(paymentid);
                newbooking = db.tblBookings.Where(q => q.paymentId == paymentid).FirstOrDefault();
                if (newbooking != null)
                {
                    newbooking.CancellationBit = "1";

                    db.SaveChanges();
                }
                else
                {
                    return(NotFound());
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(Ok());
        }
Example #6
0
        public IHttpActionResult PuttblBooking(string id, tblBooking tblBooking)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != tblBooking.BID)
            {
                return(BadRequest());
            }

            db.Entry(tblBooking).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!tblBookingExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Example #7
0
        public ActionResult ViewBill(int id)
        {
            tblConsignment con = dc.tblConsignments.SingleOrDefault(ob => ob.ConsignmentId == id);

            ViewBag.UserName = (from ob in dc.tblUsers where ob.UserId == con.UserId select ob).Take(1).SingleOrDefault().FirstName;
            string Name = ViewBag.UserName;


            tblBooking book = dc.tblBookings.SingleOrDefault(ob => ob.ConsignmentId == con.ConsignmentId);
            tblBidding bid  = dc.tblBiddings.SingleOrDefault(ob => ob.BidId == book.BidId);

            ViewBag.Company    = (from ob in dc.tblTransportCompanies where ob.CompanyId == bid.CompanyId select ob).Take(1).SingleOrDefault().CompanyName;
            ViewBag.Weburl     = (from ob in dc.tblTransportCompanies where ob.CompanyId == bid.CompanyId select ob).Take(1).SingleOrDefault().WebURL;
            ViewBag.Contact    = (from ob in dc.tblTransportCompanies where ob.CompanyId == bid.CompanyId select ob).Take(1).SingleOrDefault().ContactPersonNo;
            ViewBag.Desc       = (from ob in dc.tblBills where ob.BookingId == book.BookingId select ob).Take(1).SingleOrDefault().Desc;
            ViewBag.Price      = (from ob in dc.tblBills where ob.BookingId == book.BookingId select ob).Take(1).SingleOrDefault().Price;
            ViewBag.Tolltax    = (from ob in dc.tblBills where ob.BookingId == book.BookingId select ob).Take(1).SingleOrDefault().TollTax;
            ViewBag.GST        = (from ob in dc.tblBills where ob.BookingId == book.BookingId select ob).Take(1).SingleOrDefault().GST;
            ViewBag.TotalPrice = (from ob in dc.tblBills where ob.BookingId == book.BookingId select ob).Take(1).SingleOrDefault().TotalPrice;
            string Company = ViewBag.Company;
            string weburl  = ViewBag.Weburl;
            string cno     = ViewBag.Contact;

            return(View(con));
        }
        public ActionResult bill(FormCollection form, int id)
        {
            tblBooking     book = dc.tblBookings.SingleOrDefault(ob => ob.BookingId == id);
            tblConsignment con  = dc.tblConsignments.SingleOrDefault(ob => ob.ConsignmentId == book.ConsignmentId);
            tblUser        user = dc.tblUsers.SingleOrDefault(ob => ob.UserId == con.UserId);
            tblBidding     bid  = dc.tblBiddings.SingleOrDefault(ob => ob.BidId == book.BidId);

            ViewBag.UserName = (from ob in dc.tblUsers where ob.UserId == con.UserId select ob).Take(1).SingleOrDefault().FirstName;
            ViewBag.Company  = (from ob in dc.tblTransportCompanies where ob.CompanyId == bid.CompanyId select ob).Take(1).SingleOrDefault().CompanyName;
            ViewBag.Weburl   = (from ob in dc.tblTransportCompanies where ob.CompanyId == bid.CompanyId select ob).Take(1).SingleOrDefault().WebURL;
            ViewBag.Contact  = (from ob in dc.tblTransportCompanies where ob.CompanyId == bid.CompanyId select ob).Take(1).SingleOrDefault().ContactPersonNo;
            var com = Convert.ToInt32(Session["CompanyId"]);
            tblTransportCompany company = dc.tblTransportCompanies.SingleOrDefault(ob => ob.CompanyId == com);
            //ViewBag.Bill = (from ob in dc.tblBookings where ob.BookingId == id select ob).Take(1).SingleOrDefault().TotalPayment;
            tblBill bill = new tblBill();

            bill.BookingId  = id;
            bill.UserId     = Convert.ToInt32(user.UserId);
            bill.Desc       = form["txtDesc"];
            bill.Price      = Convert.ToInt32(book.TotalPayment);
            bill.TollTax    = Convert.ToInt32(form["txtToll"]);
            bill.GST        = (Convert.ToInt32(book.TotalPayment) * 18) / 100;
            bill.TotalPrice = Convert.ToInt32(book.TotalPayment) + Convert.ToInt32(form["txtToll"]) + (Convert.ToInt32(book.TotalPayment) * 18) / 100;
            bill.CompanyId  = Convert.ToInt32(Session["CompanyId"]);
            bill.CreatedOn  = DateTime.Now;
            dc.tblBills.Add(bill);
            dc.SaveChanges();
            return(RedirectToAction("Index", "Home"));
        }
Example #9
0
        public object ApprovalOfBooking(int BookingID, bool Approval, int ApprovedBy, decimal RatePerHour, string Reason)
        {
            var        DC         = new DataClassesDataContext();
            tblBooking BookingObj = (from ob in DC.tblBookings
                                     where ob.BookingID == BookingID
                                     select ob).Single();

            BookingObj.IsApproved = Approval;
            BookingObj.ApprovedBy = ApprovedBy;
            BookingObj.Status     = (BookingObj.IsApproved == true) ? "Accepted" : "Rejected";
            BookingObj.Reason     = (BookingObj.IsApproved == true) ? Reason : null;

            if (Approval)
            {
                tblPayment PaymentObj = new tblPayment();
                var        Amount     = (BookingObj.EndTime.Hour - BookingObj.StartTime.Hour) * RatePerHour;
                PaymentObj.Amount       = Amount;
                PaymentObj.DueDate      = BookingObj.StartTime.Date.AddDays(-1);
                PaymentObj.InitiateDate = DateTime.Now;
                PaymentObj.PaymentFor   = Convert.ToInt32(BookingObj.FlatNo);
                PaymentObj.PaymentName  = "Facility Booking";
                PaymentObj.Penalty      = 0;
                PaymentObj.IsActive     = true;

                DC.tblPayments.InsertOnSubmit(PaymentObj);
            }

            DC.SubmitChanges();

            return(true);
        }
        public ActionResult Updatebook(tblBooking E)
        {
            tblBooking s = (tblBooking)Session["opp"];     // retrieving that object by session variable so we can retrieve booking id by this
            string     m = Dbclass.GetbookData(E, s);      //here updation is done

            ViewBag.msg = m;
            return(View("bookingupdate"));
        }
        public ActionResult bill(int id)
        {
            tblBooking booking = dc.tblBookings.SingleOrDefault(ob => ob.BookingId == id);

            ViewBag.Price = booking.TotalPayment;
            tblBill bill = dc.tblBills.SingleOrDefault(ob => ob.BookingId == id);

            return(View(bill));
        }
        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);
        }
        public ActionResult EditBook(int id)
        {
            int        CompanyID = Convert.ToInt32(Session["CompanyId"]);
            tblBooking book      = dc.tblBookings.SingleOrDefault(ob => ob.ConsignmentId == id);
            var        drivers   = from obDriver in dc.tblDrivers where obDriver.CompanyId == CompanyID select obDriver;
            var        vehicles  = from obVehicle in dc.tblVehicles where obVehicle.CompanyId == CompanyID select obVehicle;

            ViewBag.driver  = new SelectList(drivers, "DriverId", "DriverName");
            ViewBag.vehicle = new SelectList(vehicles, "VehicleId", "VehicleName");
            return(View(book));
        }
        public ActionResult AddBid(int id, int id1)
        {
            tblBooking book = new tblBooking();

            book.ConsignmentId = id;
            book.BidId         = id1;
            //book.IsPaid = false;
            dc.tblBookings.Add(book);
            dc.SaveChanges();
            return(RedirectToAction("Index", "Home"));
        }
Example #15
0
        public IHttpActionResult PosttblBooking(tblBooking tblBooking)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            //db.tblBookings.Add(tblBooking);
            db.proc_Booking(tblBooking.UserID);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = tblBooking.BID }, tblBooking));
        }
Example #16
0
        public ActionResult Detail(int id)
        {
            tblBooking book = dc.tblBookings.SingleOrDefault(ob => ob.BookingId == id);

            ViewBag.Vehicle  = (from ob in dc.tblVehicles where ob.VehicleId == book.VehicleId select ob).Take(1).SingleOrDefault().VehicleName;
            ViewBag.Driver   = (from ob in dc.tblDrivers where ob.DriverId == book.DriverId select ob).Take(1).SingleOrDefault().DriverName;
            ViewBag.UserName = (from ob in dc.tblUsers join ob2 in dc.tblConsignments on ob.UserId equals ob2.UserId where ob2.ConsignmentId == book.ConsignmentId select ob).Take(1).SingleOrDefault().FirstName;
            ViewBag.Pic      = (from ob in dc.tblUsers join ob2 in dc.tblConsignments on ob.UserId equals ob2.UserId where ob2.ConsignmentId == book.ConsignmentId select ob).Take(1).SingleOrDefault().ProfilePic;
            string vehicle = ViewBag.Vehicle;
            string dr      = ViewBag.Driver;

            return(View(book));
        }
Example #17
0
        public IHttpActionResult DeletetblBooking(string id)
        {
            tblBooking tblBooking = db.tblBookings.Find(id);

            if (tblBooking == null)
            {
                return(NotFound());
            }

            db.tblBookings.Remove(tblBooking);
            db.SaveChanges();

            return(Ok(tblBooking));
        }
Example #18
0
        public JsonResult Active(int id)
        {
            tblBooking book = dc.tblBookings.SingleOrDefault(ob => ob.BookingId == id);

            if (book.IsPaid == true)
            {
                book.IsPaid = false;
            }
            else
            {
                book.IsPaid = true;
            }
            dc.SaveChanges();
            return(Json(book.IsPaid, JsonRequestBehavior.AllowGet));
        }
 public ActionResult DeleteBooking(int id)
 {
     if (Session["StudioID"] == null && Session["StudioName"] == null && Session["StudioPhoneNo"] == null)
     {
         return(RedirectToAction("Login", "Login"));
     }
     try
     {
         tblBooking booking = db.tblBookings.Find(id);
         db.tblBookings.Remove(booking);
         db.SaveChanges();
         return(Json(new { success = true, message = "Record deleted successfully" }, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         return(Json(new { success = false, message = "Record not deleted" + ex.Message }, JsonRequestBehavior.AllowGet));
     }
 }
Example #20
0
        /* Vendors */

        /* Events */

        /* Events */

        /* FacilityBookings */

        public object ProposeFacilityBooking(int FacilityID, string FlatNo, string StartTime, string EndTime, string Purpose, string Description)
        {
            var        DC         = new DataClassesDataContext();
            tblBooking BookingObj = new tblBooking();

            BookingObj.FacilityID  = FacilityID;
            BookingObj.FlatNo      = FlatNo;
            BookingObj.StartTime   = Convert.ToDateTime(StartTime);
            BookingObj.EndTime     = Convert.ToDateTime(EndTime);
            BookingObj.Status      = "Panel Review Pending";
            BookingObj.Purpose     = Purpose;
            BookingObj.Description = Description;
            BookingObj.IsApproved  = false;
            BookingObj.IsActive    = true;

            DC.tblBookings.InsertOnSubmit(BookingObj);
            DC.SubmitChanges();

            return("True");
        }
        public IHttpActionResult uncreatebookings(string Source_B, string Destination_B, string StartDate, string StartTime, float TravelFare, string EmailId, string BusNo, string SelectedSeats, string TicketType, string paymentBy)
        {
            dbNewBusEntities8 db       = new dbNewBusEntities8();
            tblBooking        customer = new tblBooking();

            customer.Source_B      = Source_B;
            customer.Destination_B = Destination_B;
            customer.StartDate     = StartDate;
            customer.StartTime     = StartTime;
            customer.TravelFare    = TravelFare;
            customer.EmailId       = EmailId;
            customer.BusNo         = BusNo;
            customer.SelectedSeats = SelectedSeats;
            customer.paymentBy     = paymentBy;
            // customer.WalletDetails = wallet;
            customer.TicketType      = TicketType;
            customer.CancellationBit = "0";
            db.tblBookings.Add(customer);
            db.SaveChanges();
            return(Ok());
        }
        public ActionResult ApproveBooking()
        {
            try
            {
                int      CustomerID         = Convert.ToInt32(Request.Form["CustomerID"]);
                string   BookingDescription = Request.Form["BookingDescription"];
                DateTime FunctionDate       = Convert.ToDateTime(Request.Form["FunctionDate"]);

                tblBooking booking = new tblBooking();
                booking.CustomerID         = CustomerID;
                booking.BookingDescription = BookingDescription;
                booking.FunctionDate       = FunctionDate;
                booking.CreatedDate        = DateTime.Now;
                booking.IsExposed          = false;
                db.tblBookings.Add(booking);
                db.SaveChanges();
                return(Json(new { success = true, message = "Booking Approved Successfully" }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new { success = false, message = "Error!" + ex.Message }, JsonRequestBehavior.AllowGet));
            }
        }
        public ActionResult DeleteExpose(int id)
        {
            if (Session["StudioID"] == null && Session["StudioName"] == null && Session["StudioPhoneNo"] == null)
            {
                return(RedirectToAction("Login", "Login"));
            }
            try
            {
                tblExposing exposing = db.tblExposings.Find(id);
                tblBooking  booking  = db.tblBookings.SingleOrDefault(b => b.BookingID == exposing.BookingID);
                booking.IsExposed       = false;
                booking.UpdatedDate     = DateTime.Now;
                db.Entry(booking).State = EntityState.Modified;

                db.tblExposings.Remove(exposing);
                db.SaveChanges();
                return(Json(new { success = true, message = "Record deleted successfully" }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new { success = false, message = "Record not deleted" + ex.Message }, JsonRequestBehavior.AllowGet));
            }
        }
        public ActionResult payment1(tblPayment p)
        {
            if (ModelState.IsValid)                             //if validations are satisfied then it goes into model
            {
                tblBooking z = (tblBooking)Session["var"];      //here we are retrieving tblbooking object values that are stored in session variable


                bool s = Dbclass.getpayment(p);
                if (s == true)                                 //if payment is done successfully then it goes to insertion of booking
                {
                    string x = Dbclass.getbooking(z);          //for inserting into booking
                    ViewBag.g = x;
                }
                return(View());
            }
            else
            {
                ViewBag.msg    = Session["bill"].ToString();
                slist          = Dbclass.getstate();
                ViewBag.bankid = slist;
                return(View("payment"));                       //it will show where the validation is missing
            }
        }
        public ActionResult Exposing()
        {
            try
            {
                int    BookingID          = Convert.ToInt32(Request.Form["BookingID"]);
                int    PhotographerID     = Convert.ToInt32(Request.Form["PhotographerID"]);
                string BookingDescription = Request.Form["BookingDescription"];
                string Address            = Request.Form["Address"];

                tblExposing exposing = new tblExposing();
                tblBooking  booking  = db.tblBookings.SingleOrDefault(b => b.BookingID == BookingID);

                exposing.BookingID      = BookingID;
                exposing.PhotographerID = PhotographerID;
                if (BookingDescription.Trim().Equals("1"))
                {
                    exposing.Description = booking.BookingDescription;
                    booking.IsExposed    = true;
                }
                else
                {
                    exposing.Description = BookingDescription;
                }

                exposing.Location    = Address;
                exposing.CreatedDate = DateTime.Now;

                db.tblExposings.Add(exposing);
                db.Entry(booking).State = EntityState.Modified;
                db.SaveChanges();
                return(Json(new { success = true, message = "Event exposed successfully." }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new { success = false, message = "Error!" + ex.Message }, JsonRequestBehavior.AllowGet));
            }
        }
 public object CreateFbk(Feedback feedbk)
 {
     try
     {
         tblBooking  tblBooking = new tblBooking();
         tblFeedback fb         = new tblFeedback();
         fb.Question1 = feedbk.Question1;
         fb.Question2 = feedbk.Question2;
         fb.Question3 = feedbk.Question3;
         fb.Question4 = feedbk.Question4;
         fb.Question5 = feedbk.Question5;
         db.tblFeedbacks.Add(fb);
         db.SaveChanges();
         return(new Response
         {
             Status = "Success",
             Message = "SuccessFully Saved."
         });
     }
     catch (Exception)
     {
         throw;
     }
 }
 public int AddBooking(tblBooking objBooking)
 {
     db.tblBookings.Add(objBooking);
     db.SaveChanges();
     return(objBooking.ID);
 }
Example #28
0
        public string SaveTheftClaim(TheftClaimModel model)
        {
            string path = Path.Combine(HttpContext.Current.Server.MapPath("~/PdfTemplates"), "TheftClaimPDF.html");

            model.FullName = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(model.FullName.ToLower());
            int bookingid;

            try
            {
                bookingid = Convert.ToInt32(model.BookingId);
            }
            catch (Exception ex)
            {
                bookingid = 0;
            }
            tblBooking tblBooking = ((IQueryable <tblBooking>) this._dbEntity.tblBookings).FirstOrDefault <tblBooking>((Expression <Func <tblBooking, bool> >)(x => x.BookingId == (long)bookingid));

            if (tblBooking != null)
            {
                tblBooking.IsTheftClaimRaised    = new bool?(true);
                tblBooking.IsRenterRaisedDispute = new bool?(true);
                this._dbEntity.SaveChanges();
            }
            string   str1      = System.IO.File.ReadAllText(path).Replace("{fullname}", model.FullName).Replace("{email}", model.Email);
            string   oldValue1 = "{dob}";
            DateTime dateTime  = model.DOB.Date;
            string   newValue1 = dateTime.ToString("MM-dd-yyyy");
            string   str2      = str1.Replace(oldValue1, newValue1).Replace("{booking}", model.BookingId).Replace("{address}", model.Address).Replace("{postcode}", model.PostCode).Replace("{mobilenumber}", model.MobileNumber).Replace("{circumstances}", model.Circumstances).Replace("{stolenlist}", model.ListOfStolenItems).Replace("{approxvalue}", "£ " + model.ApproxValue).Replace("{responsible}", model.WhoWasResponsible).Replace("{unattended}", model.HowLongUnattended);
            string   oldValue2 = "{lastseen}";

            dateTime = model.TimeAndDateLastSeen;
            string newValue2 = dateTime.ToString();
            string str3      = str2.Replace(oldValue2, newValue2);
            string oldValue3 = "{discovered}";

            dateTime = model.TimeAndDateTheftDiscovered;
            string newValue3 = dateTime.ToString();
            string str4      = str3.Replace(oldValue3, newValue3);
            bool?  nullable  = model.IsAnyWitness;
            bool   flag1     = true;
            string str5      = ((nullable.GetValueOrDefault() == flag1 ? (nullable.HasValue ? 1 : 0) : 0) == 0 ? str4.Replace("{anywitness}", "No").Replace("{witnessdetails}", string.Empty) : str4.Replace("{anywitness}", "Yes").Replace("{witnessdetails}", model.WitnessDetails)).Replace("{policecontact}", model.PoliceContactNumber).Replace("{crimeincident}", model.CrimeIncidentNumber);
            string str6      = !model.IsPoliceAttend ? str5.Replace("{policeattend}", "No") : str5.Replace("{policeattend}", "Yes");
            string str7      = (!model.IsReportedToPoliceImmediately ? str6.Replace("{policeimmediately}", "No").Replace("{reasonforpolice}", model.ReasonForNotReportedImmediately) : str6.Replace("{policeimmediately}", "Yes").Replace("{reasonforpolice}", string.Empty)).Replace("{howsecured}", model.HowBicycleWasSecured).Replace("{locksecured}", model.DetailOfSecuredLock).Replace("{howaccess}", model.HowAccessGained).Replace("{alternatesecurity}", model.AlternativeSecurityMethod);

            nullable = model.IsAnotherInsurer;
            bool   flag2 = true;
            string str8  = ((nullable.GetValueOrDefault() == flag2 ? (nullable.HasValue ? 1 : 0) : 0) == 0 ? str7.Replace("{isanotherinsurer}", "No") : str7.Replace("{isanotherinsurer}", "Yes")).Replace("{previousinsurer}", model.PreviousInsurerName).Replace("{expirydate}", model.ExpiryDate).Replace("{anybicycleclaim}", model.PastClaimDetails);

            nullable = model.IsAnyCriminalConviction;
            bool   flag3 = true;
            string str9  = (nullable.GetValueOrDefault() == flag3 ? (nullable.HasValue ? 1 : 0) : 0) == 0 ? str8.Replace("{iscriminal}", "No") : str8.Replace("{iscriminal}", "Yes");

            nullable = model.IsPolicyCancelled;
            bool   flag4 = true;
            string str10 = (nullable.GetValueOrDefault() == flag4 ? (nullable.HasValue ? 1 : 0) : 0) == 0 ? str9.Replace("{ispolicycancelled}", "No") : str9.Replace("{ispolicycancelled}", "Yes");

            nullable = model.IsRefusedRenewal;
            bool         flag5        = true;
            string       str11        = ((nullable.GetValueOrDefault() == flag5 ? (nullable.HasValue ? 1 : 0) : 0) == 0 ? str10.Replace("{isrefusedrenewal}", "No") : str10.Replace("{isrefusedrenewal}", "Yes")).Replace("{provideddetails}", model.ProvidedDetails);
            StreamWriter streamWriter = new StreamWriter(HostingEnvironment.MapPath("~/Templates/dfTemplate.htm"));

            streamWriter.Write(str11);
            streamWriter.Close();
            streamWriter.Dispose();
            PdfConverter pdfConverter = new PdfConverter();

            pdfConverter.LicenseKey = "elFLWktaTE9IWk9USlpJS1RLSFRDQ0ND";
            pdfConverter.PdfDocumentOptions.PdfPageSize           = PdfPageSize.Letter;
            pdfConverter.PdfDocumentOptions.PdfCompressionLevel   = PdfCompressionLevel.NoCompression;
            pdfConverter.PdfDocumentOptions.PdfPageOrientation    = PDFPageOrientation.Landscape;
            pdfConverter.PdfDocumentOptions.BottomMargin          = 20;
            pdfConverter.PdfDocumentOptions.TopMargin             = 20;
            pdfConverter.PdfDocumentOptions.LeftMargin            = 20;
            pdfConverter.PdfDocumentOptions.RightMargin           = 20;
            pdfConverter.PdfDocumentOptions.ShowHeader            = false;
            pdfConverter.PdfDocumentOptions.ShowFooter            = false;
            pdfConverter.PdfDocumentOptions.AutoSizePdfPage       = false;
            pdfConverter.PdfDocumentOptions.GenerateSelectablePdf = true;
            pdfConverter.PdfDocumentOptions.SinglePage            = true;
            string str12 = RandomString(7) + ".pdf";

            byte[] pdfBytesFromUrl = pdfConverter.GetPdfBytesFromUrl(HostingEnvironment.MapPath("~/Templates/dfTemplate.htm"));
            System.IO.File.WriteAllBytes(HostingEnvironment.MapPath("~/PdfTemplates/TheftClaimForms/" + str12 ?? ""), pdfBytesFromUrl);
            model.PDFName = str12;
            Mapper.Initialize(new MapperConfigurationExpression()
            {
                AllowNullCollections = true, AllowNullDestinationValues = true, CreateMissingTypeMaps = true
            });

            tblTheftClaim tblTheftClaim = Mapper.Instance.Map <tblTheftClaim>(model);

            tblTheftClaim.IsApproved  = new bool?(false);
            tblTheftClaim.CreatedDate = new DateTime?(DateTime.Now);
            this._dbEntity.tblTheftClaims.Add(tblTheftClaim);
            this._dbEntity.SaveChanges();
            return("Success");
        }
Example #29
0
        public bool DeliveredTracking(int Statusid, int BookingId, int OfficeId, int Userid)
        {
            var data        = db.Trackings.Where(m => m.BookingId == BookingId).ToList();
            var bookingdata = db.tblBookings.Where(m => m.ID == BookingId).ToList();
            int?CreatedBy   = 0;

            foreach (var item in data)
            {
                CreatedBy = item.CreatedBy;
                break;
            }
            Tracking   te;
            tblBooking be;

            foreach (var item in data)
            {
                te                 = db.Trackings.Find(item.Id);
                te.IsCurrent       = false;
                db.Entry(te).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();
                te = null;
            }
            foreach (var item in bookingdata)
            {
                be                 = db.tblBookings.Find(item.ID);
                be.IsCurrent       = false;
                db.Entry(be).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();
                be = null;
            }
            bool cntr         = true;
            int  newBookingId = 0;

            foreach (var item in bookingdata)
            {
                if (cntr)
                {
                    tblBooking newBooking = new tblBooking();
                    newBooking.Amount           = item.Amount;
                    newBooking.CreatedBy        = item.CreatedBy;
                    newBooking.CreatedDate      = item.CreatedDate;
                    newBooking.DestinationId    = item.DestinationId;
                    newBooking.IsActive         = true;
                    newBooking.Userid           = CreatedBy;
                    newBooking.IsCurrent        = true;
                    newBooking.IsDelivered      = true;
                    newBooking.IsPickUp         = true;
                    newBooking.OfficeId         = OfficeId;
                    newBooking.PackageDetailsId = item.PackageDetailsId;
                    newBooking.PaymentType      = item.PaymentType;
                    newBooking.ShipmentId       = item.ShipmentId;
                    newBooking.SourceId         = item.SourceId;
                    newBooking.TransactionId    = item.TransactionId;
                    newBooking.UpdatedBy        = Userid;
                    newBooking.UpdatedDate      = DateTime.Now;
                    db.tblBookings.Add(newBooking);
                    db.SaveChanges();
                    newBookingId = newBooking.ID;
                    cntr         = false;
                    break;
                }
            }
            var      officelist = db.Offices.Where(m => m.Id == OfficeId).FirstOrDefault();
            string   City       = officelist.BranchLocation;
            Tracking te1        = new Tracking();

            te1.IsActive          = true;
            te1.IsCurrent         = true;
            te1.IsDelivered       = true;
            te1.UpdatedBy         = Userid;
            te1.CreatedBy         = CreatedBy;
            te1.CargoStatusTypeId = Statusid;
            te1.CurrentLocation   = City;
            te1.BookingId         = newBookingId;
            db.Trackings.Add(te1);
            db.SaveChanges();
            return(true);
        }
Example #30
0
        public string CaptureSecuirtyById(long id)
        {
            try
            {
                string     host           = ConfigurationManager.AppSettings["Host"];
                string     from           = ConfigurationManager.AppSettings["FromEmail"];
                string     insurerEmail   = ConfigurationManager.AppSettings["InsurerEmail"];
                string     password       = ConfigurationManager.AppSettings["Password"];
                int        port           = Convert.ToInt32(ConfigurationManager.AppSettings["Port"]);
                tblBooking bookingDetails = ((IQueryable <tblBooking>) this._dbEntity.tblBookings).FirstOrDefault <tblBooking>((Expression <Func <tblBooking, bool> >)(x => x.BookingId == id));
                if (bookingDetails == null)
                {
                    return(string.Empty);
                }


                string str1 = string.Empty;
                if (bookingDetails.IsSecurityByPaypal == true)
                {
                    if (!string.IsNullOrEmpty(bookingDetails.SecurityId))
                    {
                        try
                        {
                            bool captureId = PayPalImplement.CaptureAuthorization(bookingDetails.SecurityId);
                            str1 = "ok";
                            bookingDetails.IsSecurityCaptureOrRefund = new bool?(true);
                            this._dbEntity.SaveChanges();
                        }
                        catch (Exception ex)
                        {
                            str1 = string.Empty;
                        }
                    }
                }
                else
                {
                    str1 = "ok";
                }

                bookingDetails.IsSecurityCaptureOrRefund = new bool?(true);
                this._dbEntity.SaveChanges();

                if (!string.IsNullOrEmpty(str1))
                {
                    List <tblUserDeviceMapping> list = ((IQueryable <tblUserDeviceMapping>) this._dbEntity.tblUserDeviceMappings).Where <tblUserDeviceMapping>((Expression <Func <tblUserDeviceMapping, bool> >)(x => x.UserId == bookingDetails.UserId)).ToList <tblUserDeviceMapping>();
                    if (list != null && list.Count > 0)
                    {
                        List <PushNotificationModel> devicelist = new List <PushNotificationModel>();
                        foreach (tblUserDeviceMapping userDeviceMapping in list)
                        {
                            devicelist.Add(new PushNotificationModel()
                            {
                                DeviceToken = userDeviceMapping.DeviceToken,
                                Message     = "Security amount has been captured by BiblioVélo for your booking with Booking Id: " + (object)bookingDetails.BookingId
                            });
                        }
                        PushNotifications.PushToIphone(devicelist);
                    }
                    tblUser     userDetails = ((IQueryable <tblUser>) this._dbEntity.tblUsers).FirstOrDefault <tblUser>((Expression <Func <tblUser, bool> >)(x => (long?)x.Id == bookingDetails.UserId));
                    tblLogin    tblLogin    = ((IQueryable <tblLogin>) this._dbEntity.tblLogins).FirstOrDefault <tblLogin>((Expression <Func <tblLogin, bool> >)(x => (long?)x.Id == userDetails.LoginId));
                    MailMessage message     = new MailMessage();
                    string      str2        = System.IO.File.ReadAllText(Path.Combine(HttpContext.Current.Server.MapPath("~/EmailTemplate"), "MailTemplate.html")).Replace("{UserName}", userDetails.FirstName + ",");
                    string      empty       = string.Empty;
                    string      newValue    = "Security amount has been captured/hold by BiblioVélo for your booking with Booking Id:" + (object)bookingDetails.BookingId;
                    string      str3        = str2.Replace("{Message}", newValue);
                    string      email       = tblLogin.Email;
                    string      str4        = "Security Amount Captured By BiblioVélo";

                    message.From = new MailAddress(from, "BiblioVélo Support");
                    message.To.Add(email);
                    message.Subject    = str4;
                    message.IsBodyHtml = true;
                    message.Body       = str3;
                    SmtpClient smtpClient = new SmtpClient(host, port);

                    smtpClient.EnableSsl   = true;
                    smtpClient.Credentials = new NetworkCredential(from, password);
                    try
                    {
                        smtpClient.Send(message);
                    }
                    catch (SmtpException ex1)
                    {
                        Common.ExcepLog(ex1);
                    }
                }
                return(str1);
            }

            catch (Exception ex)
            {
                Common.ExcepLog(ex);
                return(string.Empty);
            }
        }