Пример #1
0
        public async Task <bool> Update(OfferDto obj)
        {
            DataAccess.Models.Offer value = Mapper.Map <DataAccess.Models.Offer>(obj);

            try
            {
                db.Entry(value).State = EntityState.Modified;

                foreach (var files in db.Files)
                {
                    db.Entry(files).State = EntityState.Modified;
                }

                await db.SaveChangesAsync();

                return(true);
            }
            catch (Exception ex)  { return(false); }
        }
Пример #2
0
        public async Task <bool> Delete(OfferDto obj)
        {
            try
            {
                DataAccess.Models.Offer value = Mapper.Map <DataAccess.Models.Offer>(obj);

                value.DeletedDateTime = DateTime.Now;
                value.IsDeleted       = true;

                db.Entry(value).State = EntityState.Modified;

                await db.SaveChangesAsync();

                return(true);
            }
            catch
            {
                return(false);
            }
        }
Пример #3
0
        public async Task <bool> Create(OfferDto obj)
        {
            try
            {
                DataAccess.Models.Offer value = Mapper.Map <DataAccess.Models.Offer>(obj);

                value.DatePublication = DateTime.Now;

                db.Entry(value).State = EntityState.Added;

                db.Offers.Add(value);

                await db.SaveChangesAsync();

                return(true);
            }
            catch
            {
                return(false);
            }
        }