コード例 #1
0
        public ActionResult klerk(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            NewBooking NewBookings = db.NewBookings.Find(id);


            var          doc          = new Document();
            MemoryStream memoryStream = new MemoryStream();
            PdfWriter    writer       = PdfWriter.GetInstance(doc, memoryStream);

            doc.Open();
            doc.Add(new Paragraph("*****OCEAN LAND LOGISTICS*****"));
            doc.Add(new Paragraph("**INVOICE***"));

            doc.Add(new Paragraph("Job Id    :" + NewBookings.BookingIds));
            doc.Add(new Paragraph("Client Name     :" + NewBookings.clientname));
            doc.Add(new Paragraph("Contact Number    :" + NewBookings.cellnum));
            doc.Add(new Paragraph("Client Email     :" + NewBookings.email));


            doc.Add(new Paragraph("Container       :" + NewBookings.ConNum));
            doc.Add(new Paragraph("Container Type  :" + NewBookings.ConType));
            doc.Add(new Paragraph("Trailer Size        :" + NewBookings.Size));
            doc.Add(new Paragraph("Collection        :" + NewBookings.Collection));
            doc.Add(new Paragraph("Drop Off         :" + NewBookings.Dropoff));
            doc.Add(new Paragraph("Total           :R" + NewBookings.final));
            doc.Add(new Paragraph("Vat amount     :R" + NewBookings.vat));


            writer.CloseStream = false;
            doc.Close();
            memoryStream.Position = 0;

            MailMessage mm = new MailMessage(NewBookings.email, NewBookings.email)
            {
                Subject    = "OLL invoice for " + NewBookings.BookingIds,
                IsBodyHtml = true,
                Body       = " Dear : " + NewBookings.clientname + " please find attached invoice for  job :" + NewBookings.BookingIds
            };

            mm.Attachments.Add(new Attachment(memoryStream, "INVOICE.pdf"));
            SmtpClient smtp = new SmtpClient
            {
                Host        = "smtp.gmail.com",
                Port        = 587,
                EnableSsl   = true,
                Credentials = new NetworkCredential("*****@*****.**", "Codex#123")
            };

            smtp.Send(mm);

            if (NewBookings == null)
            {
                return(HttpNotFound());
            }
            return(View(NewBookings));
        }
コード例 #2
0
        public async Task <IActionResult> AddBooking(NewBooking newBooking, CancellationToken token)
        {
            try
            {
                var bookingAddRequest = new AddBookingRequest()
                {
                    StartTime = newBooking.StartTime,
                    EndTime   = newBooking.EndTime,
                    PatientId = newBooking.PatientId,
                    DoctorId  = newBooking.DoctorId
                };

                await _bookingService.AddBooking(bookingAddRequest, token);

                return(Ok());
            }
            catch (ArgumentException ex)
            {
                return(BadRequest(ex.Message));
            }
            catch (Exception ex)
            {
                return(StatusCode(500, ex));
            }
        }
コード例 #3
0
        public async Task <IActionResult> CreateNewBooking(NewBooking booking)
        {
            try
            {
                DateTime[] formatedDates = BookingsHelper.formatDates(booking.startDate, booking.endDate);
                booking.startDate = formatedDates[0];
                booking.endDate   = formatedDates[1];

                List <string> errors = await BookingsHelper.validations(booking.startDate, booking.endDate, mySQLDBContext, booking.idRoom);

                errors.AddRange(BookingsHelper.validationsBooking(booking.startDate, booking.endDate, mySQLDBContext, booking.idRoom));

                if (errors.Count != 0)
                {
                    return(BadRequest(errors));
                }

                Bookings newBooking = new Bookings {
                    idRoom = booking.idRoom, startDate = booking.startDate, endDate = booking.endDate
                };
                await mySQLDBContext.AddAsync(newBooking);

                await mySQLDBContext.SaveChangesAsync();

                return(Ok(newBooking));
            }
            catch (Exception e)
            {
                logger.LogError(e.Message);
                return(StatusCode(500));
            }
        }
コード例 #4
0
        public IActionResult AddBooking(NewBooking newBooking)
        {
            var bookingId          = new Guid();
            var bookingStartTime   = newBooking.StartTime;
            var bookingEndTime     = newBooking.EndTime;
            var bookingPatientId   = newBooking.PatientId;
            var bookingPatient     = _context.Patient.FirstOrDefault(x => x.Id == newBooking.PatientId);
            var bookingDoctorId    = newBooking.DoctorId;
            var bookingDoctor      = _context.Doctor.FirstOrDefault(x => x.Id == newBooking.DoctorId);
            var bookingSurgeryType = _context.Patient.FirstOrDefault(x => x.Id == bookingPatientId).Clinic.SurgeryType;

            var myBooking = new Order
            {
                Id          = bookingId,
                StartTime   = bookingStartTime,
                EndTime     = bookingEndTime,
                PatientId   = bookingPatientId,
                DoctorId    = bookingDoctorId,
                Patient     = bookingPatient,
                Doctor      = bookingDoctor,
                SurgeryType = (int)bookingSurgeryType
            };

            _context.Order.AddRange(new List <Order> {
                myBooking
            });
            _context.SaveChanges();

            return(StatusCode(200));
        }
コード例 #5
0
        public ActionResult DeleteConfirmed(int id)
        {
            NewBooking newBooking = db.NewBookings.Find(id);

            db.NewBookings.Remove(newBooking);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #6
0
 public ActionResult Edit([Bind(Include = "BookingIds,pickupdate,clientname,cellnum,email,ConNum,ConType,Size,specInstruct,testtext,two,Distance,final,Collection,Dropoff,priorty,est,estTime,news,newss,vat")] NewBooking newBooking)
 {
     if (ModelState.IsValid)
     {
         db.Entry(newBooking).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(newBooking));
 }
コード例 #7
0
        public IActionResult AddBooking(NewBooking newBooking)
        {
            if (newBooking.StartTime < DateTime.Now)
            {
                return(StatusCode(400, new { message = "Cannot book past date" }));
            }

            var bookingId          = new Guid();
            var bookingStartTime   = newBooking.StartTime;
            var bookingEndTime     = newBooking.EndTime;
            var bookingPatientId   = newBooking.PatientId;
            var bookingPatient     = _context.Patient.FirstOrDefault(x => x.Id == newBooking.PatientId);
            var bookingDoctorId    = newBooking.DoctorId;
            var bookingDoctor      = _context.Doctor.FirstOrDefault(x => x.Id == newBooking.DoctorId);
            var bookingSurgeryType = _context.Patient.FirstOrDefault(x => x.Id == bookingPatientId).Clinic.SurgeryType;

            if (bookingDoctor.Orders.Any(o =>
                                         (o.StartTime > bookingStartTime && o.StartTime < bookingEndTime) ||
                                         (o.EndTime > bookingStartTime && o.EndTime < bookingEndTime) ||
                                         (o.StartTime < bookingStartTime && o.EndTime > bookingEndTime) ||
                                         (o.StartTime > bookingStartTime && o.EndTime < bookingEndTime) ||
                                         (o.StartTime == bookingStartTime && o.EndTime == bookingEndTime)
                                         ))
            {
                return(StatusCode(400, new { message = "Doctor is busy" }));
            }

            var myBooking = new Order
            {
                Id          = bookingId,
                StartTime   = bookingStartTime,
                EndTime     = bookingEndTime,
                PatientId   = bookingPatientId,
                DoctorId    = bookingDoctorId,
                Patient     = bookingPatient,
                Doctor      = bookingDoctor,
                SurgeryType = (int)bookingSurgeryType
            };

            _context.Order.Add(myBooking);
            _context.SaveChanges();

            return(CreatedAtAction("GetPatientBooking", new { id = myBooking.Id }, new
            {
                myBooking.Id,
                myBooking.DoctorId,
                myBooking.StartTime,
                myBooking.EndTime
            }));
        }
コード例 #8
0
        public IActionResult AddBooking(NewBooking newBooking)
        {
            var bookingRequest = new BookingRequest
            {
                DoctorId  = newBooking.DoctorId,
                PatientId = newBooking.PatientId,
                StartTime = newBooking.StartTime,
                EndTime   = newBooking.EndTime
            };

            _bookingService.MakeBooking(bookingRequest);

            return(StatusCode(200));
        }
コード例 #9
0
        // GET: NewBookings/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            NewBooking newBooking = db.NewBookings.Find(id);

            if (newBooking == null)
            {
                return(HttpNotFound());
            }
            return(View(newBooking));
        }
コード例 #10
0
        public ActionResult InvoiceDetails(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            NewBooking NewBookings = db.NewBookings.Find(id);

            if (NewBookings == null)
            {
                return(HttpNotFound());
            }
            return(View(NewBookings));
        }
コード例 #11
0
        public IActionResult AddBooking(NewBooking newBooking)
        {
            // check previous dates
            if (newBooking.StartTime < DateTime.Now)
            {
                return(StatusCode(400));
            }

            // get doctors appointments
            var bookings = _context.Order.Where(x => x.DoctorId == newBooking.DoctorId);

            // checking conflicts
            var conflicts = bookings.Where(b => (newBooking.StartTime > b.StartTime && newBooking.StartTime < b.EndTime) || newBooking.EndTime > b.StartTime && newBooking.EndTime < b.EndTime).ToList();

            if (conflicts.Count() > 0)
            {
                return(StatusCode(400));
            }

            var bookingId          = new Guid();
            var bookingStartTime   = newBooking.StartTime;
            var bookingEndTime     = newBooking.EndTime;
            var bookingPatientId   = newBooking.PatientId;
            var bookingPatient     = _context.Patient.FirstOrDefault(x => x.Id == newBooking.PatientId);
            var bookingDoctorId    = newBooking.DoctorId;
            var bookingDoctor      = _context.Doctor.FirstOrDefault(x => x.Id == newBooking.DoctorId);
            var bookingSurgeryType = _context.Patient.FirstOrDefault(x => x.Id == bookingPatientId).Clinic.SurgeryType;

            var myBooking = new Order
            {
                Id                   = bookingId,
                StartTime            = bookingStartTime,
                EndTime              = bookingEndTime,
                PatientId            = bookingPatientId,
                DoctorId             = bookingDoctorId,
                Patient              = bookingPatient,
                Doctor               = bookingDoctor,
                SurgeryType          = (int)bookingSurgeryType,
                AppointmentCancelled = false
            };

            _context.Order.AddRange(new List <Order> {
                myBooking
            });
            _context.SaveChanges();

            return(StatusCode(200));
        }
コード例 #12
0
        public IActionResult AddBooking(NewBooking newBooking)
        {
            var bookingId          = new Guid();
            var bookingStartTime   = newBooking.StartTime;
            var bookingEndTime     = newBooking.EndTime;
            var bookingPatientId   = newBooking.PatientId;
            var bookingPatient     = _context.Patient.FirstOrDefault(x => x.Id == newBooking.PatientId);
            var bookingDoctorId    = newBooking.DoctorId;
            var bookingDoctor      = _context.Doctor.FirstOrDefault(x => x.Id == newBooking.DoctorId);
            var bookingSurgeryType = _context.Patient.FirstOrDefault(x => x.Id == bookingPatientId).Clinic.SurgeryType;

            bool  validBooking  = true;
            Order existingOrder = null;

            existingOrder = _context.Order.FirstOrDefault(order => order.StartTime >= bookingStartTime && bookingEndTime <= order.EndTime.AddMinutes(15) && order.DoctorId == bookingDoctorId);

            if (bookingStartTime < DateTime.Now || bookingEndTime < DateTime.Now || existingOrder != null)
            {
                validBooking = false;
            }

            if (!validBooking)
            {
                return(StatusCode(404));
            }

            var myBooking = new Order
            {
                Id          = bookingId,
                StartTime   = bookingStartTime,
                EndTime     = bookingEndTime,
                PatientId   = bookingPatientId,
                DoctorId    = bookingDoctorId,
                Patient     = bookingPatient,
                Doctor      = bookingDoctor,
                SurgeryType = (int)bookingSurgeryType
            };

            _context.Order.AddRange(new List <Order> {
                myBooking
            });
            _context.SaveChanges();

            return(StatusCode(200));
        }
コード例 #13
0
        public IActionResult AddBooking(NewBooking newBooking)
        {
            if (newBooking.StartTime < _dateTimeProvider.UtcNow)
            {
                return(BadRequest("Unable to add a booking in the past"));
            }

            var bookingId          = new Guid();
            var bookingStartTime   = newBooking.StartTime;
            var bookingEndTime     = newBooking.EndTime;
            var bookingPatientId   = newBooking.PatientId;
            var bookingPatient     = _context.Patient.FirstOrDefault(x => x.Id == newBooking.PatientId);
            var bookingDoctorId    = newBooking.DoctorId;
            var bookingDoctor      = _context.Doctor.FirstOrDefault(x => x.Id == newBooking.DoctorId);
            var bookingSurgeryType = _context.Patient.FirstOrDefault(x => x.Id == bookingPatientId).Clinic.SurgeryType;

            var myBooking = new Order
            {
                Id          = bookingId,
                StartTime   = bookingStartTime,
                EndTime     = bookingEndTime,
                PatientId   = bookingPatientId,
                DoctorId    = bookingDoctorId,
                Patient     = bookingPatient,
                Doctor      = bookingDoctor,
                SurgeryType = (int)bookingSurgeryType
            };

            var isDoctorAvailableDuringRange = _doctorService.IsDoctorAvailableDuringRange(bookingDoctor, newBooking.StartTime, newBooking.EndTime);

            if (isDoctorAvailableDuringRange)
            {
                return(BadRequest("This timeslot is not currently available"));
            }

            _context.Order.AddRange(new List <Order> {
                myBooking
            });
            _context.SaveChanges();

            return(StatusCode(200));
        }
コード例 #14
0
        public async Task <IActionResult> Post([FromBody] NewBooking value)
        {
            yx_book book = value.Booking;

            book.Status    = "未完成";
            book.OrderNo   = GetOrderNo();
            book.CreatedAt = DateTime.Now;
            book.UpdatedAt = DateTime.Now;
            book.BookTime  = DateTime.Now;
            book.IsValid   = true;
            if (User.Identity is ClaimsIdentity identity)
            {
                book.CreatedBy = identity.Name ?? "test";
            }
            using (var tran = _context.Database.BeginTransaction())
            {
                try
                {
                    _yxBookRpt.Add(book);
                    _yxBookRpt.Commit();
                    //保存预约服务项目
                    if (value.Bookservices != null)
                    {
                        foreach (var ser in value.Bookservices)
                        {
                            ser.Id      = 0;
                            ser.OrderNo = book.OrderNo;
                            _yxBookserviceRepository.Add(ser);
                        }
                    }
                    _yxBookserviceRepository.Commit();
                    tran.Commit();
                }
                catch (Exception ex)
                {
                    tran.Rollback();
                    return(new BadRequestResult());
                }
            }
            return(new OkObjectResult(value));
        }
コード例 #15
0
 partial void UpdateNewBooking(NewBooking instance);
コード例 #16
0
 partial void DeleteNewBooking(NewBooking instance);
コード例 #17
0
        public ActionResult Create([Bind(Include = "BookingIds,pickupdate,clientname,cellnum,email,ConNum,ConType,Size,specInstruct,testtext,two,Distance,final,Collection,Dropoff,priorty,est,estTime,news,newss,vat")] NewBooking newBooking)
        {
            if (ModelState.IsValid)
            {
                //NewContainer container = new NewContainer();
                //container.ContainerID = newBooking.BookingIds;
                //container.ContainerNumber = newBooking.ConNum;
                //container.ContainerSize = newBooking.Size;
                //container.Location = newBooking.news;
                //db.NewContainers.Add(container);
                //db.SaveChanges();
                string neww = newBooking.testtext;

                neww = neww.Replace("km", "");
                neww = neww.Replace(",", "");
                neww = neww.Trim();

                string dist = neww;
                newBooking.two      = Convert.ToDouble(neww, CultureInfo.InvariantCulture);
                newBooking.two      = Math.Round(newBooking.two);
                newBooking.Distance = newBooking.testtext;

                string dur  = newBooking.est.Trim();
                double fest = Convert.ToDouble(dur, CultureInfo.InvariantCulture);
                fest = Math.Round(fest);
                newBooking.estTime = (fest / 60) / 24;
                //prices prices = new prices();
                //booking.final = booking.finalAmt();
                var    c    = db.Prices.Where(x => x.id == 1);
                double rate = Convert.ToDouble(c.Sum(y => y.rate));
                double s    = Convert.ToDouble(c.Sum(a => a.six));
                double t    = Convert.ToDouble(c.Sum(v => v.twelve));
                double ta   = Convert.ToDouble(c.Sum(w => w.tank));
                double re   = Convert.ToDouble(c.Sum(f => f.refridge));
                double p    = Convert.ToDouble(c.Sum(e => e.dry));

                double tot = 0.00;

                if (newBooking.Size == "6m" && newBooking.ConType == "Tank")
                {
                    tot = s + ta;
                }
                else if (newBooking.Size == "6m" && newBooking.ConType == "Dry Container")
                {
                    tot = s + p;
                }
                else if (newBooking.Size == "6m" && newBooking.ConType == "Refrigderated ISO")
                {
                    tot = s + re;
                }
                else if (newBooking.Size == "12m" && newBooking.ConType == "Tank")
                {
                    tot = t + ta;
                }
                else if (newBooking.Size == "12m" && newBooking.ConType == "Dry Container")
                {
                    tot = t + p;
                }
                else if (newBooking.Size == "12m" && newBooking.ConType == "Refrigderated ISO")
                {
                    tot = t + re;
                }



                //if (newBooking.two > 550 && newBooking.two < 1500)
                //{
                //    newBooking.priorty = "Medium";
                //   // newBooking.pickupdate = newBooking.pickupdate.AddDays(newBooking.estTime + 2);
                //}
                //else if (newBooking.two > 1500)
                //{
                //    newBooking.priorty = "High";
                //    newBooking.pickupdate = newBooking.pickupdate.AddDays(newBooking.estTime + 3);
                //}
                //else if (newBooking.two < 550)
                //{
                //    newBooking.priorty = "low";
                //    newBooking.pickupdate = newBooking.pickupdate.AddDays(newBooking.estTime + 1);
                //}

                //else
                //{
                //    newBooking.priorty = "Out off Range";
                //}

                var    V  = db.Vats.Where(u => u.ID == 1);
                double E  = Convert.ToDouble(V.Sum(y => y.exempt));
                double st = Convert.ToDouble(V.Sum(y => y.standardRated));
                double z  = Convert.ToDouble(V.Sum(y => y.zeroRated));


                double vvat = 0.00;
                if (newBooking.specInstruct == "Perishables")

                {
                    vvat = E + (st / 100) + z;
                }

                else
                {
                    vvat = E + (st / 100);
                }



                newBooking.final      = (newBooking.two * rate) + ((tot) * (vvat)) + (newBooking.two * rate) + (tot);
                newBooking.Collection = newBooking.news;
                newBooking.Dropoff    = newBooking.newss;
                newBooking.priorty    = newBooking.priorty;
                newBooking.vat        = newBooking.final * (st / 100);


                db.NewBookings.Add(newBooking);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(newBooking));
        }
コード例 #18
0
        public ActionResult bbdetails(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            NewBooking NewBookings = db.NewBookings.Find(id);



            string amount      = Convert.ToString(NewBookings.final);
            string orderId     = new Random().Next(1, 99999).ToString();
            string name        = NewBookings.ConNum + ", Order#" + NewBookings.BookingIds;
            string description = "To " + NewBookings.Dropoff;


            string site         = "";
            string merchant_id  = "";
            string merchant_key = "";

            // Check if we are using the mmor live system
            string paymentMode = System.Configuration.ConfigurationManager.AppSettings["PaymentMode"];

            if (paymentMode == "test")
            {
                site         = "https://sandbox.payfast.co.za/eng/process?";
                merchant_id  = "10000100";
                merchant_key = "46f0cd694581a";
            }
            else if (paymentMode == "live")
            {
                site         = "https://www.payfast.co.za/eng/process?";
                merchant_id  = System.Configuration.ConfigurationManager.AppSettings["PF_MerchantID"];
                merchant_key = System.Configuration.ConfigurationManager.AppSettings["PF_MerchantKey"];
            }
            else
            {
                throw new InvalidOperationException("Cannot process payment if PaymentMode (in web.config) value is unknown.");
            }
            // Build the query string for payment site

            StringBuilder str = new StringBuilder();

            str.Append("merchant_id=" + HttpUtility.UrlEncode(merchant_id));
            str.Append("&merchant_key=" + HttpUtility.UrlEncode(merchant_key));
            str.Append("&return_url=" + HttpUtility.UrlEncode(System.Configuration.ConfigurationManager.AppSettings["PF_ReturnURL"]));
            str.Append("&cancel_url=" + HttpUtility.UrlEncode(System.Configuration.ConfigurationManager.AppSettings["PF_CancelURL"]));
            //str.Append("&notify_url=" + HttpUtility.UrlEncode(System.Configuration.ConfigurationManager.AppSettings["PF_NotifyURL"]));

            str.Append("&m_payment_id=" + HttpUtility.UrlEncode(orderId));
            str.Append("&amount=" + HttpUtility.UrlEncode(amount));
            str.Append("&item_name=" + HttpUtility.UrlEncode(name));
            str.Append("&item_description=" + HttpUtility.UrlEncode(description));

            // Redirect to PayFast
            Response.Redirect(site + str.ToString());

            if (NewBookings == null)
            {
                return(HttpNotFound());
            }
            return(View(NewBookings));
        }
コード例 #19
0
 partial void InsertNewBooking(NewBooking instance);