/// <summary>
        ///
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int DeleteDetail(SaveDetailModels model)
        {
            int        countOfDetailDeleted = 0;
            SaveDetail saveDetail           = _db.SaveDetails.FirstOrDefault(x => x.Id == model.Id);

            if (saveDetail != null)
            {
                _db.SaveDetails.Remove(saveDetail);
                countOfDetailDeleted = _db.SaveChanges();
            }
            return(countOfDetailDeleted);
        }
        public int AddDetail(SaveDetailModels model)
        {
            SaveDetail saveDetail = new SaveDetail();

            saveDetail.Name      = model.Name;
            saveDetail.Continent = model.ContinentId;
            saveDetail.Country   = model.CountryId;
            saveDetail.City      = model.CityId;
            saveDetail.Remember  = model.Remember ?? false;
            _db.SaveDetails.Add(saveDetail);
            int countOfDetailSaved = _db.SaveChanges();

            return(countOfDetailSaved);
        }
Ejemplo n.º 3
0
        public void InsertTest()
        {
            BusinessLogic    businessLogic = new BusinessLogic();
            SaveDetailModels detailModel   = new SaveDetailModels
            {
                Name        = "Manish",
                ContinentId = 2,
                CountryId   = 5,
                CityId      = 14,
                Remember    = true
            };
            var addDetail = businessLogic.AddDetail(detailModel);

            Assert.AreNotEqual(0, addDetail);
        }
Ejemplo n.º 4
0
        public void UpdateTest()
        {
            BusinessLogic    businessLogic = new BusinessLogic();
            SaveDetailModels detailModel   = new SaveDetailModels
            {
                Id          = 3,
                Name        = "Piyush",
                ContinentId = 2,
                CountryId   = 5,
                CityId      = 14,
                Remember    = true
            };
            var updateDetail = businessLogic.UpdateDetail(detailModel);

            Assert.AreNotEqual(0, updateDetail);
        }
        public int UpdateDetail(SaveDetailModels model)
        {
            int        countOfDetailUpdated = 0;
            SaveDetail saveDetail           = _db.SaveDetails.FirstOrDefault(x => x.Id == model.Id);

            if (saveDetail != null)
            {
                saveDetail.Name      = model.Name;
                saveDetail.Continent = model.ContinentId;
                saveDetail.Country   = model.CountryId;
                saveDetail.City      = model.CityId;
                saveDetail.Remember  = model.Remember;
                countOfDetailUpdated = _db.SaveChanges();
            }
            return(countOfDetailUpdated);
        }
 public IHttpActionResult DeleteDetail([FromBody] SaveDetailModels model)
 {
     return(Ok(_businessLogic.DeleteDetail(model)));
 }