Пример #1
0
 public ActionResult Login(iproby.Data_Model.customer model)
 {
     var Login_Count = (from a in db.customers
                            where a.login == model.login
                            where a.password == model.password
                            select a.login).Count();
         if (Login_Count > 0)
         {
             Session["login"] = model.login;
             var contact_id_arr = (from a in db.customers
                                where a.login == model.login
                                where a.password == model.password
                               select a.contact_id);
             int contact_id=0;
             foreach (int item in contact_id_arr)
             {
                 contact_id = item;
             }
             var fio_arr = (from a in db.contacts
                        where a.contact_id == contact_id
                                select a.first_name);
             string fio = String.Empty;
             foreach (string item in fio_arr)
             {
                 fio = item;
             }
             Session["fio"] = fio;
             return View("~/Views/Status/LoginSuccess.cshtml");
         }
         else
         {
             return View("~/Views/Status/LoginFailed.cshtml");
         }
 }
Пример #2
0
        public ActionResult AddClients(iproby.Models.announ_clients model)
        {
            if (Session["login"] != null)
            {
                iproby.Data_Model.announ announ = new iproby.Data_Model.announ();
                announ.about = model.about;
                var type_id_arr = (from a in db.announ_type
                                   where a.type == model.type
                                   select a.id);
                int type_id = 0;
                foreach (int item in type_id_arr)
                {
                    type_id = item;
                }
                announ.type_id = type_id;
                announ.description = model.description.Replace("<", "").Replace(">", "");
                announ.header = model.header;
                announ.subjects = model.subjects;
                announ.price = model.price;
                db.announs.Add(announ);
                db.SaveChanges();

                iproby.Data_Model.customer_announ customer_announ = new iproby.Data_Model.customer_announ();
                customer_announ.announ_id = announ.id;
                string login = Session["login"].ToString();
                var customer_id_arr = (from a in db.customers
                                       where a.login == login
                                       select a.customer_id);
                int customer_id = 0;
                foreach (int item in customer_id_arr)
                {
                    customer_id = item;
                }
                customer_announ.customer_id = customer_id;
                DateTime Now = DateTime.Now;
                customer_announ.date_from = Now;
                string dateToString = "09/09/9999";
                DateTime dateTo = DateTime.Parse(dateToString, System.Globalization.CultureInfo.InvariantCulture);
                customer_announ.date_to = dateTo;
                customer_announ.active = 1;
                db.customer_announ.Add(customer_announ);
                db.SaveChanges();
                iproby.Data_Model.announ_target announ_target = new iproby.Data_Model.announ_target();
                announ_target.target_type="workers";
                announ_target.announ_id = announ.id;
                db.announ_target.Add(announ_target);
                db.SaveChanges();
                iproby.Data_Model.option options = new iproby.Data_Model.option();
                options.customer_id = customer_id;
                options.send_email_from_clients_flag = 1;
                db.options.Add(options);
                db.SaveChanges();
                service_model service_model = new service_model();
                service_model.announ_id = announ.id;
                return View("~/Views/Status/AddAnnounSuccess.cshtml", service_model);
            }
            else {
                return View("~/Views/Status/NoAuthorization.cshtml");
            }
        }
Пример #3
0
        public ActionResult AddReview(iproby.Models.review model)
        {
            if (Session["login"] != null)
            {
                string login = Session["login"].ToString();
                var customer_id_arr = (from a in db.customers
                                       where a.login == login
                                       select a.customer_id);
                int customer_id = 0;
                foreach (int item in customer_id_arr)
                {
                    customer_id = item;
                }
                iproby.Data_Model.review review = new iproby.Data_Model.review();
                review.reviewer_id = customer_id;
                review.announ_id = model.announ_id;
                review.customer_id = model.customer_id;
                var to_contact_id_arr = (from a in db.customers
                                       where a.customer_id == model.customer_id
                                          select a.contact_id);
                int to_contact_id = 0;
                foreach (int item in to_contact_id_arr)
                {
                    to_contact_id = item;
                }
                var contact_arr = (from a in db.contacts
                                       where a.contact_id == to_contact_id
                                   select a);
                string email = string.Empty;
                foreach (var item in contact_arr)
                {
                    email = item.email;
                }
                review.header = model.header;
                review.description = model.description;
                DateTime Now = DateTime.Now;
                review.date_from = Now;
                db.reviews.Add(review);
                db.SaveChanges();
                InformationController notification = new InformationController();
                notification.SendMail(email,
                @"К вашему объявлению добавили комментарий на сайте IPRO.
                Пожалуйста, проверьте в личном кабинете и по возможости напишите ответ (ответить автору сообщения возможно в Личном кабинете).

                Письмо сгенерировано автоматически. По всем вопросам пишите на [email protected]");
                isSaved = true;
                return RedirectToAction("Index", new { announ_id = model.announ_id });
            }
            else {
                notLogin = true;
                return RedirectToAction("Index", new { announ_id = model.announ_id });
            }
        }
Пример #4
0
 public ActionResult AddRequest(iproby.Models.request model)
 {
     return RedirectToAction("Index");
 }
Пример #5
0
 public ActionResult SaveOptions(iproby.Models.options model)
 {
     string login = Session["login"].ToString();
     var contact_id_arr = (from a in db.customers
                           where a.login == login
                           select a);
     int customer_id = 0;
     foreach (var item in contact_id_arr)
     {
         customer_id = item.customer_id;
     }
     var option_id = (from a in db.options
                            where a.customer_id == customer_id
                           select a.id);
     int opt_id = 0;
     foreach (var item in option_id)
     {
         opt_id = item;
     }
     var options = db.options.Find(opt_id);
     if (options != null)
     {
         options.send_email_from_clients_flag = model.send_email_from_clients;
         db.SaveChanges();
     }
     if (model.status_vip_flag == 1)
     {
         showPaymentDialog = true;
     }
     else {
         showPaymentDialog = false;
     }
     return RedirectToAction("EditOptions", "Cabinet");
 }
Пример #6
0
        public ActionResult SaveDetails(iproby.Models.announ_details model)
        {
            if (Session["login"] != null)
            {
                ViewData["login"] = "******";
                string login = Session["login"].ToString();
                var contact_id_arr = (from a in db.customers
                                      where a.login == login
                                      select a.contact_id);
                int contact_id = 0;
                foreach (int item in contact_id_arr)
                {
                    contact_id = item;
                }
                var contact = db.contacts.Find(contact_id);

                if (contact != null)
                {
                    contact.address = model.address;
                    contact.first_name = model.first_name;
                    contact.mobile = model.mobile;
                    contact.skype = model.skype;
                    contact.facebook = model.facebook;
                    contact.site = model.site;
                    contact.vkontakte = model.vkontakte;
                    contact.icq = model.icq;
                    db.SaveChanges();
                }
                isSaved = true;
                return RedirectToAction("Index");
            }
            else
            {
                isSaved = false;
                return RedirectToAction("Index");
            }
        }
Пример #7
0
        public ActionResult SaveAnnoun(iproby.Models.announ_clients model)
        {
            if (Session["login"] != null)
            {
                ViewData["login"] = "******";
                string login = Session["login"].ToString();
                var contact_id_arr = (from a in db.customers
                                      where a.login == login
                                      select a);
                int contact_id = 0; int customer_id = 0;
                foreach (var item in contact_id_arr)
                {
                    contact_id = item.contact_id;
                    customer_id = item.customer_id;
                }
                var announ_id_arr = (from a in db.customer_announ
                                     where a.customer_id == customer_id
                                     select a.announ_id);
                int announ_id = 0;
                foreach (int item in announ_id_arr)
                {
                    announ_id = item;
                }
                var announ = db.announs.Find(announ_id);

                if (announ != null)
                {
                    announ.about = model.about;
                    announ.description = model.description;
                    announ.header = model.header;
                    db.SaveChanges();
                }
                isSaved = true;
                return RedirectToAction("Index");
            }
            else
            {
                ViewData["login"] = "******";
                return View();
            }
        }
Пример #8
0
        public ActionResult EditOptions(iproby.Models.options model)
        {
            string login = Session["login"].ToString();
            var contact_id_arr = (from a in db.customers
                                  where a.login == login
                                  select a);
            int customer_id = 0;
            int confirmed_flag = 0;
            foreach (var item in contact_id_arr)
            {
                customer_id = item.customer_id;
                if (item.confirmed_flag != null) {
                confirmed_flag = item.confirmed_flag.Value;
                }
            }
            var options_arr = (from a in db.options
                                  where a.customer_id == customer_id
                                  select a);
            int flag_send_from_clients = 0;
            foreach (var item in options_arr)
            {
                flag_send_from_clients = item.send_email_from_clients_flag.Value;
            }
            iproby.Models.options options = new iproby.Models.options();
            options.customer_id = customer_id;
            options.send_email_from_clients = flag_send_from_clients;
            options.confirmed_flag = confirmed_flag;
            if (showPaymentDialog) {
                iproby.Models.payment payment = new iproby.Models.payment();
                var announ_arr = (from a in db.customer_announ
                                  where a.customer_id == customer_id
                                  select a);
                int announ_id = 0;
                foreach (var item in announ_arr)
                {
                    announ_id = item.announ_id.Value;
                }
                iproby.Data_Model.payment payment_db = new iproby.Data_Model.payment();
                payment_db.customer_id = customer_id;
                payment_db.announ_id = announ_id;
                payment_db.description = payment.desc;
                payment_db.invid = payment.invid;
                payment_db.mrchlogin = payment.mrchlogin;
                payment_db.outsum = payment.outsum.ToString();
                payment_db.date_from = DateTime.Now;
                payment_db.status = "try";

                db.payments.Add(payment_db);
                db.SaveChanges();
                payment.invid = payment_db.id;
                var payments = db.payments.Find(payment_db.id);
                if (payments != null)
                {
                    payments.invid = payment_db.id;
                    payment.invid = payment_db.id;
                    string sCrcBase = string.Format("{0}:{1}:{2}:{3}",
                                          payment.mrchlogin, payment.outsum, payment.invid, payment.password1);
                    MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
                    byte[] bSignature = md5.ComputeHash(Encoding.ASCII.GetBytes(sCrcBase));
                    StringBuilder sbSignature = new StringBuilder();
                    foreach (byte b in bSignature)
                        sbSignature.AppendFormat("{0:x2}", b);
                    string sMyCrc = sbSignature.ToString();
                    payment.signaturevalue = sMyCrc;
                    payment_db.signaturevalue = sMyCrc;
                    db.SaveChanges();
                }
                ViewData["showPaymentDialog"] = "showPaymentDialog";
                showPaymentDialog = false;
                options.payment = payment;
            }

            return View(options);
        }
Пример #9
0
        public ActionResult Registration(iproby.Models.registrator model)
        {
            if (model.first_name != null) {
                iproby.Data_Model.contact contact = new iproby.Data_Model.contact();
                contact.first_name = model.first_name;
                contact.email = Session["login"].ToString();
                contact.mobile = model.mobile;
                contact.skype = model.skype;
                contact.address = model.address;
                contact.facebook = model.facebook;
                contact.site = model.site;
                contact.vkontakte = model.vkontakte;
                contact.icq = model.icq;
                db.contacts.Add(contact);
                db.SaveChanges();

                var login=Session["login"].ToString();
                var customer_id = (from a in db.customers
                                   where a.login == login
                                   select a.customer_id);

                var customer_ex = db.customers.Find(customer_id.First());
                customer_ex.contact_id = contact.contact_id;
                db.SaveChanges();
                return RedirectToAction("Service","Catalog");
            }
            else {

            iproby.Data_Model.customer customer = new iproby.Data_Model.customer();
            //customer.contact_id = contact.contact_id;
            customer.login = model.email;
            customer.password = model.password;
            customer.status_id = 0;
            DateTime Now = DateTime.Now;
            customer.date_from = Now;
            string dateToString = "09/09/9999";
            DateTime dateTo = DateTime.Parse(dateToString, System.Globalization.CultureInfo.InvariantCulture);
            customer.date_to = dateTo;
            customer.active = 1;
            db.customers.Add(customer);
            db.SaveChanges();
            Session["fio"] = model.email;
            Session["login"] = model.email;
            InformationController notification = new InformationController();
            ConfirmationController confirmation = new ConfirmationController();
            string code = Session["login"].ToString();
            string hash_login = confirmation.GetCode(code);
            string email_text = @"
            Благодарим за регистрацию на сайте IPRO!

            Ваш логин: " + code + @"
            Пароль: " + model.password + @"

            Пожалуйста подтвердите Ваш email перейдя по ссылке http://iproby.ru/Confirmation?user_code=" + hash_login + "&login="******"
            или скопируйте текст: 'http://iproby.ru/Confirmation?user_code=" + hash_login + "&login="******"'
            в адресную строку браузера и нажмите enter.

            Спасибо!

            Письмо сгенерировано автоматически, если у вас есть вопросы пишите на почту [email protected]";
            notification.SendMail(model.email, email_text);
            return View("~/Views/Registration/RegistrationStep2.cshtml");
            }
        }
Пример #10
0
 public ActionResult SendMessage(iproby.Models.message model)
 {
     if (Session["login"] != null)
     {
         iproby.Data_Model.message message = new iproby.Data_Model.message();
         DateTime Now = DateTime.Now;
         message.date_from = Now;
         string login = Session["login"].ToString();
         var customer_id_arr = (from a in db.customers
                                where a.login == login
                                select a);
         int customer_id = 0; int contact_id = 0;
         foreach (var item in customer_id_arr)
         {
             customer_id = item.customer_id;
             contact_id = item.contact_id;
         }
         var contact_arr = (from a in db.contacts
                            where a.contact_id == contact_id
                            select a);
         string email = string.Empty;
         foreach (var item in contact_arr)
         {
             email = item.email;
         }
         message.from_customer_id = customer_id;
         message.to_customer_id = model.to_customer;
         message.header = model.header;
         message.text_mess = model.text;
         db.messages.Add(message);
         db.SaveChanges();
         InformationController notification = new InformationController();
         notification.SendMail(email, "Вам пришло сообщение на сайте IPRO. Пожалуйста проверьте в личном кабинете.");
         if (model.form_flag != null && model.form_flag == 1) {
             return RedirectToAction("Answer", "Message", new { message_id = model.message_id});
         }
         else
         {
             return View("~/Views/Status/SendMessageSuccess.cshtml");
         }
     }
     else
     {
         return View("~/Views/Status/NoAuthorization.cshtml");
     }
 }
Пример #11
0
        public ActionResult ResultPayment(iproby.Data_Model.payment model)
        {
            var invid_arr = (from a in db.payments
                                      where a.invid == model.invid
                                      select a);
                int customer_id = 0;
                foreach (var item in invid_arr)
                {
                    customer_id = item.customer_id;
                }
                var announ_arr = (from a in db.customer_announ
                                  where a.customer_id == customer_id
                                  select a);
                int announ_id = 0;
                foreach (var item in announ_arr)
                {
                    announ_id = item.announ_id.Value;
                }
                var contact_arr = (from a in db.customers
                                  where a.customer_id == customer_id
                                   join db_target1 in db.contacts on a.contact_id equals db_target1.contact_id
                                   select db_target1);
                string email = string.Empty;
                foreach (var item in contact_arr)
                {
                    email = item.email;
                }
                iproby.Models.payment paym = new iproby.Models.payment();
                // HTTP parameters
                string sOutSum = GetPrm("OutSum");
                string sInvId = GetPrm("InvId");
                string sCrc = GetPrm("SignatureValue");
                string sCrcBase = string.Format("{0}:{1}:{2}",
                                                 sOutSum, sInvId, paym.password2);
                MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
                byte[] bSignature = md5.ComputeHash(Encoding.ASCII.GetBytes(sCrcBase));
                StringBuilder sbSignature = new StringBuilder();
                foreach (byte b in bSignature)
                    sbSignature.AppendFormat("{0:x2}", b);
                string sMyCrc = sbSignature.ToString();
                string status = "success";
                if (sCrc.ToUpper() != sMyCrc.ToUpper())
                {
                    status = "signatureincorrect-" + sCrc.ToUpper() + "-" + sMyCrc.ToUpper() + "-" + sOutSum + "-" + sInvId + "-";
                }
                model.announ_id = announ_id;
                model.customer_id = customer_id;
                model.status = status;
                model.outsum = sOutSum.ToString();
                model.signaturevalue = sCrc;
                model.mrchlogin = paym.mrchlogin;
                DateTime date_from = DateTime.Now;
                model.date_from = date_from;
                if (string.IsNullOrEmpty(model.state))
                    model.state = GetPrm("State");
                if (string.IsNullOrEmpty(model.Code))
                    model.Code = GetPrm("Code");
                if (string.IsNullOrEmpty(model.Info))
                    model.Info = GetPrm("Info");
                if (string.IsNullOrEmpty(model.IncCurrLabel))
                    model.IncCurrLabel = GetPrm("IncCurrLabel");
                if (string.IsNullOrEmpty(model.PaymentMethod))
                    model.PaymentMethod = GetPrm("PaymentMethod");
                if (string.IsNullOrEmpty(model.description))
                    model.description = GetPrm("Description");
                if (string.IsNullOrEmpty(model.description))
                    model.description = paym.desc;
                if (string.IsNullOrEmpty(model.OutCurrLabel))
                    model.OutCurrLabel = GetPrm("OutCurrLabel");

                db.payments.Add(model);
                db.SaveChanges();
                iproby.Models.payment paymentModel = new iproby.Models.payment();
                paymentModel.status_text = "OK" + model.invid + "\n";
                InformationController info = new InformationController();
                string text_email=@"Благодарим за платеж!

                Данные платежа:
                id Объявления: "+announ_id+@"
                id Пользователя: "+customer_id+@"
                id Транзакции: "+model.invid+@"
                Сумма платежа: " + sOutSum + @"
                Время платежа: " +date_from.ToString()+@"
                Статус: "+status+@"

                Это сообщение сгенерировано автоматически. По всем вопросам пишите на [email protected]";
                info.SendMail(email, text_email);
                return View("~/Views/Cabinet/OKPayment.cshtml", paymentModel);
        }
Пример #12
0
        public ActionResult FailPayment(iproby.Data_Model.payment model)
        {
            var invid_arr = (from a in db.payments
                                 where a.invid == model.invid
                                 select a);
                int customer_id = 0;
                foreach (var item in invid_arr)
                {
                    customer_id = item.customer_id;
                }
                var announ_arr = (from a in db.customer_announ
                                  where a.customer_id == customer_id
                                  select a);
                int announ_id = 0;
                foreach (var item in announ_arr)
                {
                    announ_id = item.announ_id.Value;
                }
                var contact_arr = (from a in db.customers
                                   where a.customer_id == customer_id
                                   join db_target1 in db.contacts on a.contact_id equals db_target1.contact_id
                                   select db_target1);
                string email = string.Empty;
                foreach (var item in contact_arr)
                {
                    email = item.email;
                }
                iproby.Data_Model.payment payment = new iproby.Data_Model.payment();
                payment.announ_id = announ_id;
                payment.customer_id = customer_id;
                payment.invid = model.invid;
                payment.mrchlogin = model.mrchlogin;
                payment.outsum = model.outsum;
                payment.description = model.description;
                DateTime date_from = DateTime.Now;
                payment.date_from = date_from;
                payment.signaturevalue = model.signaturevalue;
                payment.Code = model.Code;
                payment.IncAccount = model.IncAccount;
                payment.IncCurrLabel = model.IncCurrLabel;
                payment.IncSum = model.IncSum;
                payment.Info = model.Info;
                payment.OutCurrLabel = model.OutCurrLabel;
                payment.PaymentMethod = model.PaymentMethod;
                payment.state = model.state;
                payment.status = "fail";
                db.payments.Add(payment);
                db.SaveChanges();
                string text_email = @"К сожалению что-то пошло не так!

                Данные платежа:
                id Объявления: " + announ_id + @"
                id Пользователя: " + customer_id + @"
                id Транзакции: " + model.invid + @"
                Сумма платежа: " + model.outsum + @"
                Время платежа: " + date_from.ToString() + @"
                Статус: fail

                Это сообщение сгенерировано автоматически. По всем вопросам пишите на [email protected]";
                InformationController info = new InformationController();
                info.SendMail(email, text_email);
                return RedirectToAction("EditOptions", "Cabinet");
        }
Пример #13
0
        public ActionResult SuccessPayment(iproby.Data_Model.payment model)
        {
            var invid_arr = (from a in db.payments
                                 where a.invid == model.invid
                                 select a);
                int customer_id = 0;
                foreach (var item in invid_arr)
                {
                    customer_id = item.customer_id;
                }
                var announ_arr = (from a in db.customer_announ
                                      where a.customer_id == customer_id
                                      select a);
                int announ_id = 0;
                foreach (var item in announ_arr)
                {
                    announ_id = item.announ_id.Value;
                }
                iproby.Models.payment paym = new iproby.Models.payment();
                // HTTP parameters
                string sOutSum = GetPrm("OutSum");
                string sInvId = GetPrm("InvId");
                string sCrc = GetPrm("SignatureValue");

                string sCrcBase = string.Format("{0}:{1}:{2}",
                                                 sOutSum, sInvId, paym.password1);
                MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
                byte[] bSignature = md5.ComputeHash(Encoding.ASCII.GetBytes(sCrcBase));
                StringBuilder sbSignature = new StringBuilder();
                foreach (byte b in bSignature)
                    sbSignature.AppendFormat("{0:x2}", b);
                string sMyCrc = sbSignature.ToString();
                string status = "success";
                if (sMyCrc.ToUpper() != sCrc.ToUpper())
                {
                    status = "2signatureincorrect-" + sCrc.ToUpper() + "-" + sMyCrc.ToUpper() + "-" + sOutSum + "-" + sInvId + "-";
                }

            iproby.Data_Model.payment payment = new iproby.Data_Model.payment();
            payment.announ_id = announ_id;
            payment.customer_id = customer_id;
            payment.invid = model.invid;
            payment.mrchlogin = paym.mrchlogin;
            payment.outsum = sOutSum.ToString();
            payment.signaturevalue = sCrc;
            payment.status = status;
            DateTime date_from = DateTime.Now;
            payment.date_from = date_from;

            if (string.IsNullOrEmpty(model.state))
                payment.state = GetPrm("State");
            else payment.state = model.state;
            if (string.IsNullOrEmpty(model.Code))
                payment.Code = GetPrm("Code");
            else payment.Code = model.Code;
            if (string.IsNullOrEmpty(model.Info))
                payment.Info = GetPrm("Info");
            else payment.Info = model.Info;
            if (string.IsNullOrEmpty(model.IncCurrLabel))
                payment.IncCurrLabel = GetPrm("IncCurrLabel");
            else payment.IncCurrLabel = model.IncCurrLabel;
            if (string.IsNullOrEmpty(model.PaymentMethod))
                payment.PaymentMethod = GetPrm("PaymentMethod");
            else payment.PaymentMethod = model.PaymentMethod;
            if (string.IsNullOrEmpty(model.description))
                payment.description = GetPrm("Description");
            else payment.description = model.description;
            if (string.IsNullOrEmpty(model.description))
                payment.description = paym.desc;
            if (string.IsNullOrEmpty(model.OutCurrLabel))
                payment.OutCurrLabel = GetPrm("OutCurrLabel");
            else payment.OutCurrLabel = model.OutCurrLabel;

            db.payments.Add(payment);
            db.SaveChanges();
            return RedirectToAction("EditOptions", "Cabinet");
        }