public ActionResult Edit(Marchent_Account marchent)
        {
            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri("http://localhost:8087/api/Marchent");

                //HTTP POST
                var putTask = client.PutAsJsonAsync <Marchent_Account>("http://localhost:8087/api/Marchent/PutMerchant", marchent);
                putTask.Wait();


                var result = putTask.Result;
                if (result.IsSuccessStatusCode)
                {
                    return(RedirectToAction("Index"));
                }
            }
            return(View(marchent));
        }
예제 #2
0
        public ActionResult CustomerSignUp(Marchent_Account marchent)
        {
            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri("http://localhost:8087/api/Marchent");

                //HTTP POST
                var postTask = client.PostAsJsonAsync("http://localhost:8087/api/Marchent/PostNewMerchant", marchent);
                postTask.Wait();

                var result = postTask.Result;
                if (result.IsSuccessStatusCode)
                {
                    return(RedirectToAction("SignIn"));
                }
                else
                {
                    IEnumerable <State> state = null;

                    var responseTask1 = client.GetAsync("http://localhost:8087/api/State/GetAllStates");
                    responseTask1.Wait();

                    var result1 = responseTask1.Result;
                    if (result1.IsSuccessStatusCode)
                    {
                        var readTask1 = result1.Content.ReadAsAsync <IList <State> >();
                        readTask1.Wait();

                        state          = readTask1.Result;
                        ViewBag.states = state;
                    }
                    else //web api sent error response
                    {
                        state          = Enumerable.Empty <State>();
                        ViewBag.states = state;
                        ModelState.AddModelError(string.Empty, "Server error. Please contact administrator.");
                    }
                }
                ModelState.AddModelError(string.Empty, "Server Error. Please contact administrator.");
                return(View(marchent));
            }
        }
        public ActionResult Details(string id)
        {
            Marchent_Account merchant = null;

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri("http://localhost:8087/api/GetMerchant");
                //HTTP GET
                var responseTask = client.GetAsync("http://localhost:8087/api/Marchent/GetAllMarchents?id=" + id.ToString());
                responseTask.Wait();

                var result = responseTask.Result;
                if (result.IsSuccessStatusCode)
                {
                    var readTask = result.Content.ReadAsAsync <Marchent_Account>();
                    readTask.Wait();

                    merchant = readTask.Result;
                }
            }

            return(View(merchant));
        }
예제 #4
0
        public ActionResult SignIn(Marchent_Account marchent, string ReturnUrl)
        {
            using (var client = new HttpClient())
            {
                if (marchent.Email_Id == "*****@*****.**" || marchent.Email_Id == "*****@*****.**")
                {
                    client.BaseAddress = new Uri("http://localhost:8087/api/Marchent");

                    //HTTP POST
                    var postTask = client.PostAsJsonAsync("http://localhost:8087/api/Marchent/PostMerchantLogin", marchent);
                    postTask.Wait();

                    var result = postTask.Result;
                    if (result.IsSuccessStatusCode)
                    {
                        var readTask1 = result.Content.ReadAsAsync <Marchent_Account>();
                        readTask1.Wait();

                        var mrchnt = readTask1.Result;
                        //============================================== for license blocking for Kannan tyres======================================================================================
                        //NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
                        //String sMacAddress = string.Empty;
                        //foreach (NetworkInterface adapter in nics)
                        //{
                        //    if (sMacAddress != "28F10E3842DB")// only return MAC Address from first card
                        //    {
                        //        IPInterfaceProperties properties = adapter.GetIPProperties();
                        //        sMacAddress = adapter.GetPhysicalAddress().ToString();
                        //    }
                        //}

                        //string HostName = Dns.GetHostName();

                        //var license = "KADAMBARI-LC-" + sMacAddress + "-" + HostName;
                        //if (license != mrchnt.License)
                        //{

                        //    ModelState.AddModelError(string.Empty, "You have no license to use. Please contact to develper. Thank you");
                        //    return View(marchent);
                        //}
                        //else
                        //{
                        //============================================== // for license======================================================================================
                        int    timeout   = mrchnt.rememberme ? 60 : 5;
                        var    ticket    = new FormsAuthenticationTicket(mrchnt.Email_Id, mrchnt.rememberme, timeout);
                        string encrypted = FormsAuthentication.Encrypt(ticket);
                        var    cookie    = new HttpCookie(FormsAuthentication.FormsCookieName, encrypted);
                        cookie.Expires  = DateTime.Now.AddMinutes(timeout);
                        cookie.HttpOnly = true;

                        Response.Cookies.Add(cookie);
                        FormsAuthentication.SetAuthCookie(mrchnt.Email_Id, mrchnt.rememberme);
                        var t = User.Identity.IsAuthenticated;
                        if (Url.IsLocalUrl(ReturnUrl))
                        {
                            return(Redirect(ReturnUrl));
                        }
                        else
                        {
                            return(RedirectToAction("Index"));
                        }

                        //}
                    }
                    else
                    {
                        ViewBag.Title = "Sign In";
                        ModelState.AddModelError(string.Empty, "Please check credentials with your e-mail.");
                        return(View(marchent));
                    }
                }
                else
                {
                    HttpResponseMessage result = null;

                    client.BaseAddress = new Uri("http://localhost:8087/api/Customer");

                    //HTTP POST
                    var postTask = client.PostAsJsonAsync("http://localhost:8087/api/Customer/PostCustomerLogin", marchent);
                    postTask.Wait();

                    result = postTask.Result;

                    if (result.IsSuccessStatusCode)
                    {
                        int    timeout   = marchent.rememberme ? 60 : 5;
                        var    ticket    = new FormsAuthenticationTicket(marchent.Email_Id, marchent.rememberme, timeout);
                        string encrypted = FormsAuthentication.Encrypt(ticket);
                        var    cookie    = new HttpCookie(FormsAuthentication.FormsCookieName, encrypted);
                        cookie.Expires  = DateTime.Now.AddMinutes(timeout);
                        cookie.HttpOnly = true;

                        Response.Cookies.Add(cookie);
                        FormsAuthentication.SetAuthCookie(marchent.Email_Id, marchent.rememberme);
                        var t = User.Identity.IsAuthenticated;
                        if (Url.IsLocalUrl(ReturnUrl))
                        {
                            return(Redirect(ReturnUrl));
                        }
                        else
                        {
                            return(RedirectToAction("Index"));
                        }
                    }
                    else
                    {
                        ViewBag.Title = "Sign In";
                        ModelState.AddModelError(string.Empty, "Please check credentials with your e-mail.");
                        return(View(marchent));
                    }
                }
            }
        }
        public IHttpActionResult PostNewMerchant([FromBody] Marchent_Account marchent)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Sorry there is some problem. Please check and try again"));
            }

            using (var ctx = new EasyBillingEntities())
            {
                if (marchent.Email_Id != null && marchent.GSTIN_Number != null && marchent.Marchent_name != null)
                {
                    //var stcode = int.Parse(marchent.stcd);
                    bool chkmndtrycredentials = false;
                    bool chkcredentialsPAN    = false;
                    bool chkcredentialsUIN    = false;
                    bool chkcredentialsCIN    = false;
                    var  chkstate             = ctx.States.Select(a => new { a.State_Code, a.Name }).Where(x => x.State_Code == marchent.State_Code).FirstOrDefault();
                    chkmndtrycredentials = ctx.Marchent_Accounts.Where(x => x.Email_Id == marchent.Email_Id || x.GSTIN_Number == marchent.GSTIN_Number).Any();

                    if (marchent.UIN_Number != null)
                    {
                        chkcredentialsUIN = ctx.Marchent_Accounts.Where(x => x.UIN_Number == marchent.UIN_Number).Any();
                    }
                    if (marchent.CIN_Number != null)
                    {
                        chkcredentialsCIN = ctx.Marchent_Accounts.Where(x => x.CIN_Number == marchent.CIN_Number).Any();
                    }
                    if (marchent.Pan_Number != null)
                    {
                        chkcredentialsPAN = ctx.Marchent_Accounts.Where(x => x.Pan_Number == marchent.Pan_Number).Any();
                    }

                    if (chkcredentialsUIN == true || chkcredentialsCIN == true || chkcredentialsPAN == true || chkmndtrycredentials == true)
                    {
                        return(BadRequest("Require fields mandotory."));
                    }
                    else
                    {
                        if (chkstate != null)
                        {
                            marchent.IsActive     = true;
                            marchent.State_Name   = chkstate.Name;
                            marchent.State_Code   = marchent.State_Code;
                            marchent.Token_number = (Guid.NewGuid()).ToString();
                            var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789,.\"';:[] }{|=+-_!@#$%^&*()/";

                            Random rd = new Random();

                            var chars1 = Enumerable.Range(0, 10)
                                         .Select(x => chars[rd.Next(0, chars.Length)]);
                            marchent.Verification_code = new string(chars1.ToArray());

                            ctx.Marchent_Accounts.Add(marchent);
                            ctx.SaveChanges();
                            SendVerificationPassToEmail(marchent.Email_Id, marchent.Verification_code);
                        }
                        else
                        {
                            return(BadRequest("State does not exists"));
                        }
                    }
                }
                else
                {
                    return(BadRequest("Require fields mandotory."));
                }
            }

            return(Ok());
        }