public async Task <ActionResult <SubDomainModel> > PostSubDomainModel(SubDomainModel subDomainModel)
        {
            _context.SubDomainModels.Add(subDomainModel);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetSubDomainModel", new { id = subDomainModel.SubDomainId }, subDomainModel));
        }
        public async Task <IActionResult> PutSubDomainModel(int id, SubDomainModel subDomainModel)
        {
            if (id != subDomainModel.SubDomainId)
            {
                return(BadRequest());
            }

            _context.Entry(subDomainModel).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SubDomainModelExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
예제 #3
0
        public List <SubDomainModel> GetSubHistoryByUserId(string UserId)
        {
            var result = new List <SubDomainModel>();
            var query  = @"select * from Subscription where UserId=@UserId";
            var conn   = Util.Util.GetDBConnection();

            conn.Open();
            SqlCommand com = new SqlCommand(query, conn);

            com.Parameters.Add(new SqlParameter("@UserId", UserId));
            var reader = com.ExecuteReader();

            while (reader.Read())
            {
                var model = new SubDomainModel();
                model.Id      = reader["Id"].ToString();
                model.UserId  = UserId;
                model.Type    = Int32.Parse(reader["Type"].ToString());
                model.Count   = Int32.Parse(reader["TicketCount"].ToString());
                model.Total   = Int32.Parse(reader["Total"].ToString());
                model.SubDate = reader["SubDate"].ToString();
                result.Add(model);
            }
            conn.Close();
            return(result);
        }
예제 #4
0
 public static SubModel GetModel(SubDomainModel model)
 {
     return(new SubModel()
     {
         Name = model.Type == 0 ? "天门山国家森林公园登山成人票" : "天门山国家森林公园登山门票+往返观光车成人票",
         Price = model.Type == 0 ? 50 : 80,
         Count = model.Count,
         Total = model.Total,
         Date = model.SubDate
     });
 }
예제 #5
0
        public bool SubscriptionTicket(SubDomainModel model)
        {
            var query = @"insert into Subscription values(@Id,@UserId,@Type,@Count,@Total,@SubDate)";
            var conn  = Util.Util.GetDBConnection();

            conn.Open();
            SqlCommand com = new SqlCommand(query, conn);

            SqlParameter[] parmas = new SqlParameter[] {
                new SqlParameter("@Id", model.Id),
                new SqlParameter("@UserId", model.UserId),
                new SqlParameter("@Type", model.Type),
                new SqlParameter("@Count", model.Count),
                new SqlParameter("@Total", model.Total),
                new SqlParameter("@SubDate", model.SubDate)
            };
            com.Parameters.AddRange(parmas);
            var result = com.ExecuteNonQuery();

            conn.Close();
            return(result > 0);
        }
예제 #6
0
 public bool SubscriptionTicket(SubDomainModel model)
 {
     return(userFunction.SubscriptionTicket(model));
 }