Beispiel #1
0
        public static int PrepareAndSendBookingEmail(BookingMaster model)
        {
            string body = string.Empty;

            using (StreamReader reader = new StreamReader(HttpContext.Current.Server.MapPath("~/Helpers/EmailTemplates/UserBookingConfirmation.html")))
            {
                body = reader.ReadToEnd();
            }
            body = body.Replace("{Name}", model.FirstName + " " + model.LastName);
            body = body.Replace("{Age}", model.Age.ToString());
            body = body.Replace("{Sex}", model.Sex == 1 ? "Male" : "Female");
            body = body.Replace("{CollectionType}", model.CollectionType == 1 ? "Collection Centre" : "Home");
            body = body.Replace("{BookingDate}", model.BookingDate.ToString());
            body = body.Replace("{Email}", model.Email);
            body = body.Replace("{Mobile}", model.Mobile);
            body = body.Replace("{Address}", model.Address);
            body = body.Replace("{Landmark}", model.Landmark);
            body = body.Replace("{PinCode}", model.PinCode);

            var C = GetCompanyDetails(1);

            body = body.Replace("{Company}", C.Name);
            body = body.Replace("{Logo}", C.LogoUrl);


            EmailServiceDTO email = new EmailServiceDTO();

            email.ToEmail      = model.Email;
            email.Status       = (int)AspectEnums.EmailStatus.Pending;
            email.Body         = body;
            email.Priority     = 2;
            email.IsAttachment = false;
            return(SendEmail(email));
        }
Beispiel #2
0
        public JsonResponse <int> AddBooking(BookingMaster booking)
        {
            JsonResponse <int> response = new JsonResponse <int>();

            if (!ModelState.IsValid)
            {
                response.FailedValidations = ModelState.Keys.ToArray();
                response.Message           = string.Format("Kindly check {0}. It is missing or in incorrect format.", response.FailedValidations[0].Split('.').LastOrDefault());
                return(response);
            }
            try
            {
                booking.CreatedDate = DateTime.Now;
                booking.IsDeleted   = 0;
                _context.BookingMasters.Add(booking);
                response.IsSuccess = _context.SaveChanges() > 0 ? true : false;

                if (response.IsSuccess)
                {
                    response.StatusCode   = "200";
                    response.Message      = "Your medical test has been booked successfully. We will send you email shortly.";
                    response.SingleResult = booking.ID;
                }
            }
            catch (Exception ex)
            {
                response.IsSuccess  = false;
                response.StatusCode = "500";
                response.Message    = ex.Message;
            }

            return(response);
        }
Beispiel #3
0
        public JsonResponse <int> SendBookingEmail(BookingMaster model)
        {
            JsonResponse <int> response = new JsonResponse <int>();

            try
            {
                EmailHelper eHelper = new EmailHelper();
                int         status  = eHelper.PrepareAndSendBookingEmail(model);

                if (status == (int)AspectEnums.EmailStatus.Sent)
                {
                    response.Message      = string.Format("Email successfully sent to {0} at {1}.", model.FirstName, model.Email);
                    response.StatusCode   = "200";
                    response.IsSuccess    = true;
                    response.SingleResult = status;
                }
                else
                {
                    response.Message      = string.Format("Could not send email to {0} at {1}.", model.FirstName, model.Email);
                    response.StatusCode   = "500";
                    response.IsSuccess    = false;
                    response.SingleResult = status;
                }
            }
            catch (Exception ex)
            {
                response.IsSuccess    = false;
                response.Message      = ex.Message;
                response.StatusCode   = "500";
                response.SingleResult = 0;
            }

            return(response);
        }
Beispiel #4
0
        public IHttpActionResult SearchBookings(BookingMaster appointment)
        {
            var appointments = new List <BookingMaster>();

            appointments = _context.BookingMasters.Where(x => x.IsDeleted == 0).ToList();
            if (appointments != null)
            {
                if (!string.IsNullOrEmpty(appointment.Email))
                {
                    appointments = appointments.Where(x => x.Email == appointment.Email).ToList();
                }
                if (!string.IsNullOrEmpty(appointment.FirstName))
                {
                    appointments = appointments.Where(x => x.FirstName == appointment.FirstName).ToList();
                }
                if (!string.IsNullOrEmpty(appointment.LastName))
                {
                    appointments = appointments.Where(x => x.LastName == appointment.LastName).ToList();
                }
                if (!string.IsNullOrEmpty(appointment.Mobile))
                {
                    appointments = appointments.Where(x => x.Mobile == appointment.Mobile).ToList();
                }
                if (!string.IsNullOrEmpty(appointment.PinCode))
                {
                    appointments = appointments.Where(x => x.PinCode == appointment.PinCode).ToList();
                }
                if (appointments.Count == 0)
                {
                    return(Ok("No such bookings found."));
                }
            }
            else
            {
                return(Ok("No booking found with data."));
            }
            return(Ok(appointments));
        }
Beispiel #5
0
        public bool SaveBooking(BookingModel model)
        {
            try
            {
                BookingMaster master = new BookingMaster();

                master.cn = model.cn;
                master.expectedDelivery = model.expectedDelivery;
                if (model.from != 0)
                {
                    master.from = model.from;
                }
                if (model.to != 0)
                {
                    master.to = model.to;
                }
                if (model.godownNo != 0)
                {
                    master.godownNo = model.godownNo;
                }

                master.paymentType  = model.paymentType;
                master.actualWeight = model.actualWeight;

                if (model.consignee != 0)
                {
                    master.consignee = model.consignee;
                }

                //second day

                master.cnNo             = model.cnNo;
                master.deliveryBranch   = model.deliveryBranch;
                master.virtualGoddownNo = model.virtualGoddownNo;
                master.consignorDetails = model.consignorDetails;
                master.consignor        = model.consignor;
                master.agentName        = model.agentName;
                master.agentDetails     = model.agentDetails;
                master.bookingType      = model.bookingType;
                master.deliveryType     = model.deliveryType;
                master.modeOfTransport  = model.modeOfTransport;
                master.invoiceNo        = model.invoiceNo;
                master.invoiceValue     = model.invoiceValue;
                master.consignorInvoice = model.consignorInvoice;
                master.freightBasis     = model.freightBasis;
                master.ftl                  = model.ftl;
                master.isCcAttached         = model.isCcAttached;
                master.isCod                = model.isCod;
                master.chargeWeight         = model.chargeWeight;
                master.freightRate          = model.freightRate;
                master.privateMark          = model.privateMark;
                master.insuredBy            = model.insuredBy;
                master.freight              = model.freight;
                master.surcharge            = model.surcharge;
                master.hamaliCharge         = model.hamaliCharge;
                master.localCartages        = model.localCartages;
                master.doorDeliveryCharge   = model.doorDeliveryCharge;
                master.statisticalCharges   = model.statisticalCharges;
                master.miscellaneousCharges = model.miscellaneousCharges;
                master.godownCharges        = model.miscellaneousCharges;
                master.cod                  = model.cod;
                master.riskCharge           = model.riskCharge;
                master.branch               = model.branch;
                master.reserveReason        = model.reserveReason;
                master.cnFrom               = model.cnFrom;
                master.srtoNo               = model.srtoNo;
                master.lotNo                = model.lotNo;
                master.meter                = model.meter;
                master.weightInKg           = model.weightInKg;

                master.isActive = true;

                _tRSEntities.BookingMasters.Add(master);
                _tRSEntities.SaveChanges();
                PackingMaster pk = new PackingMaster();
                pk.bookingId = master.id;
                foreach (var item in model.singleCn)
                {
                    pk.actualWeight = item.actualWeight1;
                    pk.packingType  = item.packingType;
                    pk.article      = item.article;
                    pk.isActive     = true;
                    _tRSEntities.PackingMasters.Add(pk);
                    _tRSEntities.SaveChanges();
                }
                return(true);
            }
            catch (Exception e)
            {
                throw e;
            }
        }