コード例 #1
0
 public List <AdvertModel> Read(string Id)
 {
     using (var db = new SQLiteDBContext())
     {
         return((from a in db.AdvertDBModel where (string.IsNullOrEmpty(Id) || a.Id == Id)select new AdvertModel {
             Title = a.Title, Description = a.Description, Price = a.Price
         }).ToList());
     }
 }
コード例 #2
0
        public async Task <string> Add(AdvertModel model)
        {
            var dbModel = _mapper.Map <AdvertDBModel>(model);

            dbModel.Id = Guid.NewGuid().ToString();
            dbModel.CreationDateTime = DateTime.UtcNow;
            dbModel.Status           = AdvertStatus.Pending;


            using (var db = new SQLiteDBContext())
            {
                db.AdvertDBModel.Add(dbModel);
                db.SaveChanges();
            }

            return(dbModel.Id);
        }