public void Delete(ReceiptBindingModel model)
 {
     using (var context = new ClinicDataBase())
     {
         using (var transaction = context.Database.BeginTransaction())
         {
             try
             {
                 Disease element = context.Diseases.FirstOrDefault(rec => rec.Id == model.Id);
                 if (element != null)
                 {
                     context.Diseases.Remove(element);
                     context.SaveChanges();
                 }
                 else
                 {
                     throw new Exception("Элемент не найден");
                 }
                 transaction.Commit();
             }
             catch
             {
                 transaction.Rollback();
                 throw;
             }
         }
     }
 }
 public void Update(ReceiptBindingModel model)
 {
     using (var context = new ClinicDataBase())
     {
         using (var transaction = context.Database.BeginTransaction())
         {
             try
             {
                 var element = context.Receipts.FirstOrDefault(rec => rec.Id == model.Id);
                 if (element == null)
                 {
                     throw new Exception("Элемент не найден");
                 }
                 CreateModel(model, element);
                 context.SaveChanges();
                 transaction.Commit();
             }
             catch
             {
                 transaction.Rollback();
                 throw;
             }
         }
     }
 }
 private Receipt CreateModel(ReceiptBindingModel model, Receipt medicine)
 {
     medicine.Dose           = model.Dose;
     medicine.PerDose        = model.PerDose;
     medicine.MedicineId     = model.MedicineId;
     medicine.SymptomaticsId = model.SymptomaticsId;
     return(medicine);
 }
예제 #4
0
        public void Delete(ReceiptBindingModel model)
        {
            var element = _receiptStorage.GetElement(new ReceiptBindingModel {
                Id = model.Id
            });

            if (element == null)
            {
                throw new Exception("Чек не найден");
            }
            _receiptStorage.Delete(model);
        }
예제 #5
0
 public List <ReceiptViewModel> Read(ReceiptBindingModel model)
 {
     if (model == null)
     {
         return(_receiptStorage.GetFullList());
     }
     if (model.Id.HasValue)
     {
         return(new List <ReceiptViewModel> {
             _receiptStorage.GetElement(model)
         });
     }
     return(_receiptStorage.GetFilteredList(model));
 }
예제 #6
0
        public void CreateOrUpdate(ReceiptBindingModel model)
        {
            var element = _receiptStorage.GetElement(new ReceiptBindingModel {
                PurchaseDate = model.PurchaseDate
            });

            if (element != null && element.Id != model.Id)
            {
                throw new Exception("Уже пробит чек в данное время");
            }
            if (model.Id.HasValue)
            {
                _receiptStorage.Update(model);
            }
            else
            {
                _receiptStorage.Insert(model);
            }
        }
예제 #7
0
        public void CreateOrUpdate(ReceiptBindingModel model)
        {
            var element = _receiptStorage.GetElement(new ReceiptBindingModel {
                Id = model.Id
            });

            if (element != null && element.Id != model.Id)
            {
                throw new Exception("Уже есть выписка с таким названием");
            }
            if (model.Id.HasValue)
            {
                _receiptStorage.Update(model);
            }
            else
            {
                _receiptStorage.Insert(model);
            }
        }
 public void Insert(ReceiptBindingModel model)
 {
     using (var context = new ClinicDataBase())
     {
         using (var transaction = context.Database.BeginTransaction())
         {
             try
             {
                 context.Receipts.Add(CreateModel(model, new Receipt()));
                 context.SaveChanges();
                 transaction.Commit();
             }
             catch
             {
                 transaction.Rollback();
                 throw;
             }
         }
     }
 }
 public List <ReceiptViewModel> GetFilteredList(ReceiptBindingModel model)
 {
     if (model == null)
     {
         return(null);
     }
     using (var context = new ClinicDataBase())
     {
         return(context.Receipts
                .Where(rec => rec.SymptomaticsId == model.SymptomaticsId)
                .Select(rec => new ReceiptViewModel
         {
             Id = rec.Id,
             Dose = rec.Dose,
             PerDose = rec.PerDose,
             MedicineId = (int)rec.MedicineId,
             SymptomaticsId = rec.SymptomaticsId
         })
                .ToList());
     }
 }
예제 #10
0
        public ReceiptViewModel GetElement(ReceiptBindingModel model)
        {
            if (model == null)
            {
                return(null);
            }

            using (var context = new ClinicDataBase())
            {
                var medicine = context.Receipts
                               .FirstOrDefault(rec => rec.Id == model.Id);
                return(medicine != null ?
                       new ReceiptViewModel
                {
                    Id = medicine.Id,
                    Dose = medicine.Dose,
                    PerDose = medicine.PerDose,
                    MedicineId = (int)medicine.MedicineId,
                    SymptomaticsId = medicine.SymptomaticsId
                } :
                       null);
            }
        }
예제 #11
0
        public async Task <IHttpActionResult> GetReceipt(string orderid)
        {
            var processingResult = new ServiceProcessingResult <ReceiptBindingModel> {
                IsSuccessful = true
            };
            //Get the order first thing to make sure we have it.
            ReceiptBindingModel Receipt = new ReceiptBindingModel();

            try
            {
                var sqlQuery = "SELECT Orders.Id,OrderId,PayType,Grade,BookType,Teacher,PersText1,Studentfname,Studentlname,Emailaddress,Schcode,ItemAmount,Itemqty,Schinvoicenumber,Orddate,ItemTotal,Schname,Yr,l1.caption as Caption1,l2.caption As Caption2,l3.caption As Caption3,l4.caption As Caption4 FROM Orders Left Join lookup l1 On l1.ivalue=Orders.icon1 Left Join lookup l2 on l2.ivalue=Orders.icon2 Left Join lookup l3 on l3.ivalue=Orders.icon3  Left Join lookup l4 on l4.ivalue=Orders.icon4  where orderid=@OrderId";
                MySqlParameter[] parameters = new MySqlParameter[] { new MySqlParameter("@OrderId", orderid) };
                var sqlQueryService         = new SQLQuery();
                var orderResult             = await sqlQueryService.ExecuteReaderAsync <OrderBindingModel>(CommandType.Text, sqlQuery, parameters);

                if (!orderResult.IsSuccessful)
                {
                    processingResult.IsSuccessful = false;
                    processingResult.Error        = new ProcessingError("There was an error retrieving your order receipt.", "There was an error retrieving your order receipt.", true, false);
                    ExceptionlessClient.Default.SubmitLog(typeof(TempOrderController).FullName, orderResult.Error.UserMessage, "Error");
                    return(Ok(processingResult));
                }
                Receipt.Items = (List <OrderBindingModel>)orderResult.Data;

                MySqlParameter[] payParameters = new MySqlParameter[] { new MySqlParameter("@OrderId", orderid) };
                var sqlQueryService1           = new SQLQuery();
                sqlQuery = "Select Schcode,PayerFname,PayerLname,Poamt,PayType,TransId, AuthCode,CustEmail,Ddate,OrderId,Schname from Payment where orderid=@OrderId";
                var payResult = await sqlQueryService.ExecuteReaderAsync <PaymentBindingModel>(CommandType.Text, sqlQuery, payParameters);

                if (!payResult.IsSuccessful)
                {
                    processingResult.IsSuccessful = false;
                    processingResult.Error        = new ProcessingError("There was an error retrieving your order receipt.", "There was an error retrieving your order receipt.", true, false);
                    ExceptionlessClient.Default.SubmitLog(typeof(TempOrderController).FullName, orderResult.Error.UserMessage, "Error");
                    return(Ok(processingResult));
                }
                List <PaymentBindingModel> payments = (List <PaymentBindingModel>)payResult.Data;
                PaymentBindingModel        payment  = payments[0];//should only be one payment
                Receipt.Schname       = payment.Schname;
                Receipt.Schcode       = payment.Schcode;
                Receipt.PayerFname    = payment.PayerFname;
                Receipt.PayerLname    = payment.PayerLname;
                Receipt.Payment       = payment.Poamt;
                Receipt.PayType       = payment.PayType;
                Receipt.TransId       = payment.TransId;
                Receipt.AuthCode      = payment.AuthCode;
                Receipt.OrderId       = payment.OrderId;
                Receipt.CustomerEmail = payment.CustEmail;
                Receipt.OrderDate     = payment.Ddate;
                Receipt.Payment       = payment.Poamt;
                processingResult.Data = Receipt;
            }
            catch (Exception ex)
            {
                ex.ToExceptionless().Submit();
                processingResult.IsSuccessful = false;
                processingResult.Error        = new ProcessingError("There was an error retrieving your order receipt.", "There was an error retrieving your order receipt.", true, false);

                return(Ok(processingResult));
            }

            return(Ok(processingResult));
            //----------------------------------------------------------------------
        }
예제 #12
0
        protected void EmailReceipt(string orderid)
        {
            //Get the order first thing to make sure we have it.
            ReceiptBindingModel Receipt = new ReceiptBindingModel();

            try
            {
                var sqlQuery = "SELECT Orders.Id,OrderId,PayType,Grade,BookType,Teacher,PersText1,Studentfname,Studentlname,Emailaddress,Schcode,ItemAmount,Itemqty,Schinvoicenumber,Orddate,ItemTotal,Schname,Yr,l1.caption as Caption1,l2.caption As Caption2,l3.caption As Caption3,l4.caption As Caption4 FROM Orders Left Join lookup l1 On l1.ivalue=Orders.icon1 Left Join lookup l2 on l2.ivalue=Orders.icon2 Left Join lookup l3 on l3.ivalue=Orders.icon3  Left Join lookup l4 on l4.ivalue=Orders.icon4  where orderid=@OrderId";
                MySqlParameter[] parameters = new MySqlParameter[] { new MySqlParameter("@OrderId", orderid) };
                var sqlQueryService         = new SQLQuery();
                var orderResult             = sqlQueryService.ExecuteReaderAsync <OrderBindingModel>(CommandType.Text, sqlQuery, parameters);
                if (!orderResult.Result.IsSuccessful)
                {
                    ExceptionlessClient.Default.CreateLog(typeof(TempOrderController).FullName, orderResult.Result.Error.UserMessage, "Error");
                }
                Receipt.Items = (List <OrderBindingModel>)orderResult.Result.Data;
                var hasAd = false;
                foreach (var order in Receipt.Items)
                {
                    switch (order.BookType)
                    {
                    case "Full Page Ad":
                        hasAd = true;
                        break;

                    case "1/2 Page Ad":
                        hasAd = true;
                        break;

                    case "1/4 Page Ad":
                        hasAd = true;
                        break;

                    case "1/8 Page Ad":
                        hasAd = true;
                        break;
                    }
                }

                MySqlParameter[] payParameters = new MySqlParameter[] { new MySqlParameter("@OrderId", orderid) };
                var sqlQueryService1           = new SQLQuery();
                sqlQuery = "Select Schcode,PayerFname,PayerLname,Poamt,PayType,TransId, AuthCode,CustEmail,Ddate,OrderId,Schname from Payment where orderid=@OrderId";
                var payResult = sqlQueryService.ExecuteReaderAsync <PaymentBindingModel>(CommandType.Text, sqlQuery, payParameters);
                if (!payResult.Result.IsSuccessful)
                {
                    ExceptionlessClient.Default.SubmitLog(typeof(TempOrderController).FullName, orderResult.Result.Error.UserMessage, "Error");
                }
                List <PaymentBindingModel> payments = (List <PaymentBindingModel>)payResult.Result.Data;
                PaymentBindingModel        payment  = payments[0];//should only be one payment
                Receipt.Schname       = payment.Schname;
                Receipt.Schcode       = payment.Schcode;
                Receipt.PayerFname    = payment.PayerFname;
                Receipt.PayerLname    = payment.PayerLname;
                Receipt.Payment       = payment.Poamt;
                Receipt.PayType       = payment.PayType;
                Receipt.TransId       = payment.TransId;
                Receipt.AuthCode      = payment.AuthCode;
                Receipt.OrderId       = payment.OrderId;
                Receipt.CustomerEmail = payment.CustEmail;
                Receipt.OrderDate     = payment.Ddate;
                Receipt.Payment       = payment.Poamt;

                var body = "";

                var hbody = "<div class='form-group col-md-12'><label style = 'font-size:x-large' ><strong>Thank you for your payment</strong></label></div>"
                            + "<div  class='form-group'><div class='col-sm-6'><strong>School Name: </strong>" + payment.Schname + "</div></div>"
                            + "<div class='form-group'> <div class='col-sm-6'><strong>School Code: </strong>" + payment.Schcode + "</div></div>"
                            + " <div class='form-group'> <div class='col-sm-6'><strong>Payer Name: </strong>" + payment.PayerFname + " " + payment.PayerLname + "</div></div>"
                            + " <div class='form-group'> <div class='col-sm-6'><strong>Order Date: </strong>" + payment.Ddate.ToString("MM/dd/yyyy") + "</div></div>"
                            + "<div class='form-group'>  <div class='col-sm-6'><strong>Order Id: </strong>" + payment.OrderId + "</div></div>"
                            + "<div class='form-group'>  <div class='col-sm-6'><strong>Pay Type: </strong>" + payment.PayType + "</div></div>"

                            + "<div class='form-group'><div class='col-sm-6'><strong>Transaction Id: </strong>" + payment.TransId + "</div></div>"
                            + "<div class='form-group'><div class='col-sm-6'><strong>Authorization Code: </strong>" + payment.AuthCode + "</div></div>"
                            + "<div class='form-group'><div class='col-sm-6'><strong>Amount Paid: </strong>$" + payment.Poamt + "</div> </div><div></div>";
                body = hbody;
                if (hasAd)
                {
                    body = body + "<div style = 'font-size:larger' ><strong ><a href = 'http://mbcadpages.v5.pressero.com/' target = '_blank'> You have ordered an ad. Click here to configure your ad. (http://mbcadpages.v5.pressero.com/)</a></strong></div>";
                }
                body = body + "<div style='color: red; margin - bottom:5px'><i>If you have questions about your order contact your school's yearbook advisor. </i></div><hr>";
                foreach (var order in Receipt.Items)
                {
                    var items = "<div style='margin:7px'><table>"
                                + "<tr><td style='text-align:right'><strong> Item Quantity: </strong ></td><td>" + order.Itemqty + "</td></tr>"
                                + "<tr><td style='text-align:right'><strong> Item: </strong></td><td> " + order.BookType + "</td></tr>"
                                + "<tr><td style='text-align:right'><strong> Student Name: </strong></td><td> " + order.Studentfname + " " + order.Studentlname + "</td></tr>"
                                + "<tr><td style='text-align:right'><strong> Teacher: </strong></td><td>" + order.Teacher + "</td></tr>"
                                + "<tr><td style='text-align:right'><strong> Grade: </strong></td><td>" + order.Grade + "</td></tr>";
                    var text = "";
                    if (order.PersText1 != "" && order.PersText1 != "Not Available")
                    {
                        if (order.BookType == "Love Line")
                        {
                            text  = "<tr><td style='text-align:right'><strong>Love Line: </strong></td><td >" + order.PersText1 + "</td></tr>";
                            items = items + text;
                        }
                        else if (order.BookType != "Love Line" && order.PersText1 != "")
                        {
                            text  = "<tr><td style='text-align:right'><strong>Personalized Text :</strong></td><td>" + order.PersText1 + "</td></tr>";
                            items = items + text;
                        }
                    }
                    var icontext = "";
                    if (order.BookType == "Personalized Ink Yearbook" || order.BookType == "Personalized Foil Yearbook")
                    {
                        icontext = "<tr><td style='text-align:right'><strong>Icons: </strong></td><td style='font-size:xx-small'><i>" + order.Caption1 + " " + order.Caption2 + " " + order.Caption3 + " " + order.Caption4 + "</i></td></tr>";
                        items    = items + icontext;
                    }
                    items = items + "<tr><td style='text-align:right'>Item Amount: </td><td>$" + order.ItemTotal + "</td ></tr></table></div><div></div><hr>";
                    body  = body + items;
                }


                var emailhelper = new Utilities.EmailHelper();

                emailhelper.SendEmail("Receipt for a Parent Payment to Memory Book Company (Transaction Id " + Receipt.TransId + ")  Using " + Receipt.PayType + "  " + DateTime.Now.ToShortDateString(), Receipt.CustomerEmail, "", "*****@*****.**", body, Utils.EmailType.Mbc);
            }
            catch (Exception ex)
            {
                ex.ToExceptionless()
                .MarkAsCritical()
                .SetMessage("Failed to send receipt email.")
                .Submit();
            }
        }
예제 #13
0
        protected void EmailSchoolReceipt(string transid)
        {
            //Get the order first thing to make sure we have it.
            ReceiptBindingModel Receipt = new ReceiptBindingModel();

            try
            {
                var sqlQuery = "SELECT Schname,Schcode,PayerFname,PayerLname,Poamt,PayType,TransId,AuthCode,CustEmail,Ddate,OrderId from Payment  where transid=@Transid";
                MySqlParameter[] parameters = new MySqlParameter[] { new MySqlParameter("@Transid", transid) };
                var sqlQueryService         = new SQLQuery();
                var payResult = sqlQueryService.ExecuteReaderAsync <PaymentBindingModel>(CommandType.Text, sqlQuery, parameters);
                if (!payResult.Result.IsSuccessful)
                {
                    ExceptionlessClient.Default.CreateLog(typeof(OrderController).FullName, payResult.Result.Error.UserMessage, "Error");
                }

                List <PaymentBindingModel> payments = (List <PaymentBindingModel>)payResult.Result.Data;
                PaymentBindingModel        payment  = payments[0];//should only be one payment
                Receipt.Schname       = payment.Schname;
                Receipt.Schcode       = payment.Schcode;
                Receipt.PayerFname    = payment.PayerFname;
                Receipt.PayerLname    = payment.PayerLname;
                Receipt.Payment       = payment.Poamt;
                Receipt.PayType       = payment.PayType;
                Receipt.TransId       = payment.TransId;
                Receipt.AuthCode      = payment.AuthCode;
                Receipt.OrderId       = payment.OrderId;
                Receipt.CustomerEmail = payment.CustEmail;
                Receipt.OrderDate     = payment.Ddate;
                Receipt.Payment       = payment.Poamt;

                var body = "";

                var hbody = "<div class='form-group col-md-12'><label style = 'font-size:x-large' ><strong>Thank you for your payment</strong></label></div>"
                            + "<div  class='form-group'><div class='col-sm-6'><strong>School Name: </strong>" + payment.Schname + "</div></div>"
                            + "<div class='form-group'> <div class='col-sm-6'><strong>School Code: </strong>" + payment.Schcode + "</div></div>"
                            + " <div class='form-group'> <div class='col-sm-6'><strong>Payer Name: </strong>" + payment.PayerFname + " " + payment.PayerLname + "</div></div>"
                            + " <div class='form-group'> <div class='col-sm-6'><strong>Order Date: </strong>" + payment.Ddate.ToString("MM/dd/yyyy") + "</div></div>"
                            + "<div class='form-group'>  <div class='col-sm-6'><strong>Pay Type: </strong>" + payment.PayType + "</div></div>"

                            + "<div class='form-group'><div class='col-sm-6'><strong>Transaction Id: </strong>" + payment.TransId + "</div></div>"
                            + "<div class='form-group'><div class='col-sm-6'><strong>Authorization Code: </strong>" + payment.AuthCode + "</div></div>"
                            + "<div class='form-group'><div class='col-sm-6'><strong>Amount Paid: </strong>$" + payment.Poamt + "</div> </div><div></div>";
                body = hbody;

                //body = body + "<div style='color: red; margin - bottom:5px'><i>If you have questions about your order contact your schools yearbook advisor. </i></div><hr>";



                var emailhelper = new Utilities.EmailHelper();

                emailhelper.SendEmail("Receipt for a School Payment to Memory Book Company (Transaction Id " + Receipt.TransId + ")  Using " + Receipt.PayType + "  " + DateTime.Now.ToShortDateString(), Receipt.CustomerEmail, "", "*****@*****.**", body, Utils.EmailType.Mbc);
            }
            catch (Exception ex)
            {
                ex.ToExceptionless()
                .MarkAsCritical()
                .SetMessage("Failed to send receipt email.")
                .Submit();
            }
        }