Beispiel #1
0
        public async Task <bool> Update(TypeOfOfferDto typeOfOfferDto)
        {
            DataAccess.Models.TypeOfOffer value = Mapper.Map <DataAccess.Models.TypeOfOffer>(typeOfOfferDto);

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

                await db.SaveChangesAsync();

                return(true);
            }
            catch { return(false); }
        }
        public async Task <ActionResult> Delete(TypeOfOfferDto value)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    await db.Delete(value);

                    return(RedirectToAction("Index"));
                }
            }
            catch
            {
                ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
            }
            return(View("index"));
        }
Beispiel #3
0
        public async Task <bool> Create(TypeOfOfferDto typeOfOfferDto)
        {
            try
            {
                DataAccess.Models.TypeOfOffer value = Mapper.Map <DataAccess.Models.TypeOfOffer>(typeOfOfferDto);

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

                db.TypeOfOffers.Add(value);

                await db.SaveChangesAsync();

                return(true);
            }
            catch
            {
                return(false);
            }
        }
Beispiel #4
0
        public async Task <bool> Delete(TypeOfOfferDto typeOfOfferDto)
        {
            try
            {
                DataAccess.Models.TypeOfOffer value = Mapper.Map <DataAccess.Models.TypeOfOffer>(typeOfOfferDto);

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

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

                await db.SaveChangesAsync();

                return(true);
            }
            catch
            {
                return(false);
            }
        }
Beispiel #5
0
        public TypeOfOfferDto Get(int id)
        {
            TypeOfOfferDto value = Mapper.Map <TypeOfOfferDto>(db.TypeOfOffers.Find(id));

            return(value);
        }