Beispiel #1
0
        public async Task<IHttpActionResult> Register3()
        //public async Task<HttpResponseMessage>  Register2()
        {

            var contentType = Request.Content.Headers.ContentType.MediaType;
            var pp = System.Web.HttpContext.Current.Request["RegisterBindingModel"];

            RegisterBindingModel foo = Newtonsoft.Json.JsonConvert.DeserializeObject<RegisterBindingModel>(pp) as RegisterBindingModel;

            //  JsonSerializer serializer = JsonSerializer.Create(Configuration.Formatters.JsonFormatter.SerializerSettings);

            //  var requestParams = Request.Content.ReadAsStringAsync().Result;


            var httpRequest = HttpContext.Current.Request;



            if (httpRequest.Files.Count > 0)
            {
                foreach (string file in httpRequest.Files)
                {
                    var files = new List<string>();
                    if (file == "FileUpload")
                    {

                        var postedFile = httpRequest.Files[file];
                        var vfile = postedFile.FileName.Replace("\"", string.Empty).Replace("'", string.Empty);

                        vfile = Stp(vfile);
                        string FileName = HttpContext.Current.Server.MapPath("~/Img/" + vfile);
                        //   dd.cac_file = "/images/" + vfile;

                        foo.LogoPath = "Img/" + vfile;

                        postedFile.SaveAs(FileName);



                    }
                }

            }



            var user = new ApplicationUser() { UserName = foo.Email, Email = foo.Email, LogoPath = foo.LogoPath, Security_Question = foo.Security_Question, First_Name = foo.First_Name, Surname_Name = foo.Surname_Name, PhoneNumber = foo.PhoneNumber, Security_Answer = foo.Security_Answer, Subscription_Type = foo.Subscription_Type };
            foo.Password = CreatePassword(8);

            IdentityResult result = await UserManager.CreateAsync(user, foo.Password);

          //  ApplicationUser vv = UserManager.FindByEmail(foo.Email);
            ApplicationUser vv = UserManager.FindByEmail(foo.Email);




            IdentityResult result2 = await UserManager.AddToRoleAsync(vv.Id, "CORPORATE");
            var _db = new ApplicationDbContext();
            foreach (String ssd in foo.Services)
            {
                User_Detail gs = new User_Detail();
                gs.Fee_amount = foo.Fee_amount;
                gs.Services = ssd;
                
                gs.User_Id = foo.Email;
                gs.Fee = foo.Fee;

                _db.User_Detail.Add(gs);
                _db.SaveChanges();


            }
            foreach (String ssd in foo.Services)
            {
                Subscription_Detail2 hh = new Subscription_Detail2();
                hh.Payment_Date = DateTime.Now;
                hh.Subscription_Code = foo.Subscription_Type;
                hh.user_id = foo.Email;
                hh.Transaction_Code = "";
                hh.Service = ssd;
                if (foo.Fee)
                {

                    AddSubscription_Detail3(hh);

                }

            }
            // result = await UserManager.AddToRoleAsync(vv.Id, "INSTITUTION");

            //if (!result.Succeeded)
            //{

            //    return GetErrorResult(result);
            //}
            //  return   Request.CreateErrorResponse(HttpStatusCode.Created,
            //  "Record Successfully Created");

            sendemail2(foo.Email, foo.Email, foo.Password);   
            return Ok();
        }
Beispiel #2
0
        public void  AddSubscription_Detail3(Subscription_Detail2 foo)
        {

            string parameter1 = "";

            var httpRequest = HttpContext.Current.Request;





            try
            {
                var _db = new ApplicationDbContext();
                //  string currentUserId = User.Identity.GetUserId();
                Subscription_Details aaa = new Subscription_Details();
                aaa.Payment_Date = foo.Payment_Date;
                aaa.Subscription_Code = foo.Subscription_Code;

                aaa.user_id = foo.user_id;
                aaa.Transaction_id = foo.Transaction_Code;
                aaa.Service = foo.Service;
                aaa.Used = false;

                if (foo.Subscription_Code == "NG002")
                {

                    aaa.Expiry_Date = foo.Payment_Date.AddMonths(1);
                }

                else if (foo.Subscription_Code == "NG003")
                {

                    aaa.Expiry_Date = foo.Payment_Date.AddYears(1);
                }

                else
                {

                    aaa.Expiry_Date = null;
                }



                _db.Subscription_Details.Add(aaa);

                var kk = _db.SaveChanges();

                var cc = (from c in _db.Transaction where c.Transaction_Code == foo.Transaction_Code select c).FirstOrDefault();

                cc.Payment_Status = "Paid";

                _db.SaveChanges();

                //   _db.SaveChanges();
                //   return aaa.Transaction_Code;

             //   return Ok();

            }
            catch (Exception ee)
            {
             //   return BadRequest(); ;
                // return ee.Message; ;
            }




        }
Beispiel #3
0
        public async Task<IHttpActionResult> AddSubscription_Detail2(Subscription_Detail2 foo)
        {

            string parameter1 = "";

            var httpRequest = HttpContext.Current.Request;





            try
            {
                var _db = new ApplicationDbContext();
                //  string currentUserId = User.Identity.GetUserId();
                Subscription_Detail2 aaa = new Subscription_Detail2();
                aaa.Payment_Date = foo.Payment_Date;
                aaa.Subscription_Code = foo.Subscription_Code;
             
                aaa.user_id = foo.user_id;
              //  aaa.us = false;
                aaa.Transaction_Code = foo.Transaction_Code;

                //if (foo.Subscription_Code == "NG002")
                //{

                //    aaa.Expiry_Date = foo.Payment_Date.AddMonths(1);
                //}

                //else
                //{

                //    aaa.Expiry_Date = null;
                //}

                var foo3 = (from c in _db.Users where c.UserName == foo.user_id select c).FirstOrDefault();

                if (foo3.Institution_Code != null)
                {
                    var foo4 = (from c in _db.User_Detail where c.User_Id == foo.user_id select c).ToList();

                    foreach (var kd in foo4)
                    {

                        aaa.Service = kd.Services;
                        AddSubscription_Detail3(aaa);
                    }



                }

                else
                {

                    AddSubscription_Detail3(aaa);

                }

                //_db.Subscription_Details.Add(aaa);

                //var kk = _db.SaveChanges();

                var cc = (from c in _db.Transaction where c.Transaction_Code == foo.Transaction_Code select c).FirstOrDefault();

                cc.Payment_Status = "Paid";

                _db.SaveChanges();

                //   _db.SaveChanges();
             //   return aaa.Transaction_Code;

                return Ok();

            }
            catch (Exception ee)
            {
                return BadRequest(); ;
               // return ee.Message; ;
            }




        }
Beispiel #4
0
        public async Task<String> AddTransaction2(Transaction foo2)
        {



            var httpRequest = HttpContext.Current.Request;





            try
            {
                var _db = new ApplicationDbContext();
                var foo = (from c in _db.Transaction where c.Order_Id == foo2.Order_Id select c).FirstOrDefault();

                var foo3 = (from c in _db.Users where c.UserName == foo.user_id select c).FirstOrDefault();
                //  string currentUserId = User.Identity.GetUserId();
                //Transaction aaa = new Transaction();
                //foo.amount = foo2.amount;
                //foo.Bank_Code = foo2.Bank_Code;
                //aaa.Institution_Code = foo.Institution_Code;
                if (foo2.Transaction_Status == "Approved")
                {
                    foo.Payment_Status = "Approved";
                }

                else
                {

                    foo.Payment_Status = "Declined";
                }
                //aaa.Subscription_Code = foo.Subscription_Code;
              
                //aaa.Transaction_Code =foo.Transaction_Code;
                //aaa.payment_type = foo.payment_type;
                //aaa.Account_Number = foo.Account_Number;
                //aaa.user_id = foo.user_id;
               foo.Status = "Unused";
                //aaa.Order_Id = foo.Order_Id;
                foo.Transaction_Date = DateTime.Now;
                foo.Transaction_Status = foo2.Transaction_Status;
              
                    foo.Transaction_Code = foo2.Transaction_Code;
              
              //  _db.Transaction.Add(aaa);

                var kk = _db.SaveChanges();

                Subscription_Detail2 hh = new Subscription_Detail2();
                hh.Payment_Date = DateTime.Now;
                hh.Subscription_Code = foo2.Subscription_Code;
                hh.user_id = foo2.user_id;
                hh.Transaction_Code = foo2.Transaction_Code;
                hh.Service = foo2.Service;
                if (foo.Transaction_Status == "Approved") {

                    if (foo3.Institution_Code != null)
                    {
                        var foo4 = (from c in _db.User_Detail where c.User_Id == foo.user_id select c).ToList();

                        foreach (var kd in foo4)
                        {

                            hh.Service = kd.Services;
                            AddSubscription_Detail3(hh);
                        }



                    }

                    else
                    {

                        AddSubscription_Detail3(hh);

                    }

                }
                //   _db.SaveChanges();
                return foo2.Transaction_Code;

            }
            catch (Exception ee)
            {
                return ee.Message; ;
            }




        }