Exemplo n.º 1
0
        public void Delete(ReligionViewModel model)
        {
            var item = _repository.FindById(model.Id);

            if (item != null)
            {
                _repository.Delete(item);
            }
        }
Exemplo n.º 2
0
        public ActionResult ReligionDetail(int?id)
        {
            ReligionViewModel model = new ReligionViewModel();

            if (id.HasValue)
            {
                model = new ReligionRepository().GetByID((int)id);
            }
            return(PartialView("_Religion", model));
        }
Exemplo n.º 3
0
        public void Create(ReligionViewModel religionViewModel)
        {
            var Religion = new Religion
            {
                ReligionName = religionViewModel.ReligionName
            };

            unitOfWork.ReligionRepository.Insert(Religion);
            unitOfWork.Save();
        }
Exemplo n.º 4
0
 public ActionResult Delete(ReligionViewModel model)
 {
     try
     {
         service.Delete(model);
         service.Save();
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Exemplo n.º 5
0
        public void Update(ReligionViewModel religionViewModel)
        {
            var Religion = new Religion
            {
                ReligionId   = religionViewModel.ReligionId,
                ReligionName = religionViewModel.ReligionName
            };


            unitOfWork.ReligionRepository.Update(Religion);

            unitOfWork.Save();
        }
Exemplo n.º 6
0
        // GET: Country/Details/5
        public ActionResult Details(int id = 0)
        {
            if (id == 0)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ReligionViewModel religionViewModel = ReligionServices.GetByID(id);

            if (religionViewModel == null)
            {
                return(HttpNotFound());
            }
            return(View(religionViewModel));
        }
Exemplo n.º 7
0
 public ActionResult Create(ReligionViewModel religionViewModel)
 {
     try
     {
         // TODO: Add insert logic here
         ReligionServices.Create(religionViewModel);
         TempData["message"] = "Inserted Successfully";
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
        /// <summary>
        /// To the view model.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <returns></returns>
        public static ReligionViewModel ToViewModel(this ReligionModel model)
        {
            if (model == null)
            {
                return(null);
            }

            var entity = new ReligionViewModel
            {
                ReligionID = model.ReligionID,
                Religion   = model.Religion
            };

            return(entity);
        }
        /// <summary>
        /// To the model.
        /// </summary>
        /// <param name="entity">The entity.</param>
        /// <returns></returns>
        public static ReligionModel ToModel(this ReligionViewModel entity)
        {
            if (entity == null)
            {
                return(null);
            }

            var model = new ReligionModel
            {
                ReligionID = entity.ReligionID,
                Religion   = entity.Religion
            };

            return(model);
        }
Exemplo n.º 10
0
        public JsonResult SaveReligion(ReligionViewModel model)
        {
            ResponseData result = new Models.ResponseData();

            if (model.RelD != 0)
            {
                result = new ReligionRepository().UpdateByEntity(model);
            }
            else
            {
                result = new ReligionRepository().AddByEntity(model);
            }

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 11
0
        public ActionResult Edit(ReligionViewModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    service.Update(model);
                    service.Save();
                    return(RedirectToAction("Index"));
                }

                return(View(model));
            }
            catch
            {
                return(View());
            }
        }
Exemplo n.º 12
0
 public ResponseData UpdateByEntity(ReligionViewModel newdata)
 {
     using (SATEntities db = new SATEntities())
     {
         ResponseData result = new Models.ResponseData();
         try
         {
             var data = db.tb_Religion.Single(x => x.RelD == newdata.RelD);
             data.RelName    = newdata.RelName;
             data.RelStatus  = (newdata.Status == "1") ? true : false;
             data.ModifyBy   = UtilityService.User.UserID;
             data.ModifyDate = DateTime.Now;
             db.SaveChanges();
         }
         catch (Exception)
         {
         }
         return(result);
     }
 }
Exemplo n.º 13
0
        public ActionResult Edit(ReligionViewModel religionViewModel)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    // TODO: Add update logic here

                    ReligionServices.Update(religionViewModel);
                    TempData["message"] = "Update Successfully";
                    return(RedirectToAction("Index"));
                }
                catch
                {
                    return(View());
                }
            }

            return(View());
        }
Exemplo n.º 14
0
 public ResponseData AddByEntity(ReligionViewModel data)
 {
     using (SATEntities db = new SATEntities())
     {
         ResponseData result = new Models.ResponseData();
         try
         {
             tb_Religion model = new tb_Religion();
             model.RelD       = data.RelD;
             model.RelName    = data.RelName;
             model.RelStatus  = (data.Status == "1") ? true : false;
             model.CreateBy   = UtilityService.User.UserID;
             model.CreateDate = DateTime.Now;
             model.ModifyBy   = UtilityService.User.UserID;
             model.ModifyDate = DateTime.Now;
             db.tb_Religion.Add(model);
             db.SaveChanges();
         }
         catch (Exception)
         {
         }
         return(result);
     }
 }
Exemplo n.º 15
0
        public void Insert(ReligionViewModel model)
        {
            var contractType = AutoMapper.Mapper.Map <ReligionViewModel, Religion>(model);

            _repository.Add(contractType);
        }
Exemplo n.º 16
0
 public static Religion MapViewModelToModel(this ReligionViewModel entity)
 {
     return(Mapper.Map <ReligionViewModel, Religion>(entity));
 }
Exemplo n.º 17
0
        public void Update(ReligionViewModel model)
        {
            var contractType = AutoMapper.Mapper.Map <ReligionViewModel, Religion>(model);

            _repository.Update(contractType);
        }