//public List<TypeMasterVM> GetAllTypes() //{ // var typeList = _TypeRepository.GetAll(x => x.IsDeleted == false); // List<TypeMasterVM> typeVMList = new List<TypeMasterVM>(); // foreach (var item in typeList) // { // TypeMasterVM typeVM = new TypeMasterVM(); // typeVM.Type = item.Type; // typeVM.TypeId = item.TypeId; // typeVMList.Add(typeVM); // } // return typeVMList; //} //public List<TypeMasterVM> GetAllTypes(PagingVM pageparam) //{ // PagingVM1 param = new PagingVM1(); // param.page = pageparam.page; // param.PageSize = pageparam.pageSize; // var typeList = _TypeRepository.GetAll(param, x => x.TypeId,x=>x.IsDeleted==false); // List<TypeMasterVM> typeVMList = new List<TypeMasterVM>(); // if (typeList != null) // { // foreach (var item in typeList.ToList()) // { // TypeMasterVM typeVM = new TypeMasterVM(); // typeVM.Type = item.Type; // typeVM.TypeId = item.TypeId; // typeVMList.Add(typeVM); // } // } // return typeVMList; //} public TypeMasterVM GetByIdType(int id) { var type = _TypeRepository.GetById(id); TypeMasterVM typeVM = new TypeMasterVM(); typeVM.Type = type.Type; typeVM.TypeId = type.TypeId; return(typeVM); }
public ActionResult AddOrEditType(TypeMasterVM typeVM) { try { if (ModelState.IsValid) { bool status = false; if (typeVM.TypeId == 0) { status = _TypeSerivce.AddType(typeVM); if (status) { return(Json(new { success = true, message = "Saved Successfully...!" }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { success = false, message = "Error..!" }, JsonRequestBehavior.AllowGet)); } } else { status = _TypeSerivce.UpdateType(typeVM); if (status) { return(Json(new { success = true, message = "Updated Successfully...!" }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { success = false, message = "Error..!" }, JsonRequestBehavior.AllowGet)); } } } else { return(PartialView(typeVM)); } } catch (Exception e) { throw e; } }
public ActionResult AddOrEditType(int id = 0) { if (Session["User"] != null) { TypeMasterVM typeVM = new TypeMasterVM(); if (id == 0) { //add return(PartialView(typeVM)); } else { //update typeVM = _TypeSerivce.GetByIdType(id); return(PartialView(typeVM)); } } else { return(RedirectToAction("Login", "LoginForm")); } }
public bool UpdateType(TypeMasterVM _TypeVM) { try { if (_TypeVM != null) { tblTypeMaster _type = _TypeRepository.GetById(_TypeVM.TypeId); _type.Type = _TypeVM.Type; _type.TypeId = _TypeVM.TypeId; _type.IsDeleted = false; _TypeRepository.Update(_type); _unitOfWork.Complete(); return(true); } else { return(false); } } catch (Exception e) { throw e; } }