コード例 #1
0
ファイル: AccountController.cs プロジェクト: ozotony/UPS
        public async Task<IHttpActionResult> AddSubscription(Subscription foo)
        {

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

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

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

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


            var httpRequest = HttpContext.Current.Request;





            try
            {
                var _db = new ApplicationDbContext();
                string currentUserId = User.Identity.GetUserId();
                Subscription aaa = new Subscription();
                aaa.Subscription_Code = foo.Subscription_Code;
                aaa.Subscription_Name = foo.Subscription_Name;
                aaa.Subscription_Type_Code = foo.Subscription_Type_Code;
                aaa.Amount = foo.Amount;

                _db.Subscription.Add(aaa);

                var kk = _db.SaveChanges();
                //   _db.SaveChanges();
                return Ok();

            }
            catch (Exception ee)
            {
                return BadRequest(); ;
            }




        }
コード例 #2
0
ファイル: AccountController.cs プロジェクト: ozotony/UPS
          public List<Subscription> GetSubscriptionCode([FromUri] String property1)
          {
              var _db = new ApplicationDbContext();
              var vv = (from c in _db.Subscription

                        join o in _db.Subscription_Type on new { a = c.Subscription_Type_Code } equals new { a = o.Subscription_Type_Code }
                        where ((c.Subscription_Code == property1))

                        //    where ((c.DateCreated.Date == start_date) && (c.DateCreated.Date <= end_date))
                        //      where (c.DateCreated.Date >= start_date.Date && c.DateCreated.Date <= end_date.Date)



                        select new { c.Subscription_Code, c.Subscription_Name, o.Subscription_Type_Name, c.Amount }).ToList();

              List<Subscription> kk = new List<Subscription>();
              foreach (var dd in vv)
              {
                  Subscription xx = new Subscription();
                  xx.Amount = dd.Amount;
                  xx.Subscription_Code = dd.Subscription_Code;
                  xx.Subscription_Name = dd.Subscription_Name;
                  xx.Subscription_Type_Code = dd.Subscription_Type_Name;

                  kk.Add(xx);

              }



              // var ccd = (from c in _db.Subscription_Type select c).ToList();





              return kk;
          }