public bool UpdateUserType(UserTypeEntity userTypeEntity) { try { using (SqlConnection con = new SqlConnection(Connection.dbConnection)) { con.Open(); using (SqlCommand cmd = new SqlCommand("usp_UpdateUserType", con)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@UserTypeID", userTypeEntity.UserTypeID); cmd.Parameters.AddWithValue("@UserTypeName", userTypeEntity.UserTypeName); cmd.Parameters.AddWithValue("@UserTypeDesc", userTypeEntity.UserTypeDesc == null ? "" : userTypeEntity.UserTypeDesc); cmd.Parameters.AddWithValue("@ModifiedBy", userTypeEntity.ModifiedBy); cmd.Parameters.AddWithValue("@ModifiedOn", userTypeEntity.ModifiedOn); int cnt = cmd.ExecuteNonQuery(); //int userTypeID = Convert.ToInt32(cmd.Parameters["@UserTypeID"].Value); if (cnt > 0) { return(true); } else { return(false); } } } } catch (Exception ex) { return(false); } return(true); }
public ActionResult AddUserType(int userTypeID = 0) { UserTypeEntity userTypeEntity = new UserTypeEntity(); UserTypeModel userTypeModel = new UserTypeModel(); try { if (userTypeID > 0) { userTypeEntity = userTypeBAL.GetUserTypeByID(userTypeID); userTypeModel = AutoMapper.Mapper.Map <UserTypeEntity, UserTypeModel>(userTypeEntity); return(PartialView("_AddUserType", userTypeModel)); } else { return(PartialView("_AddUserType", new UserTypeModel())); } } catch (Exception) { throw; } finally { userTypeEntity = null; userTypeModel = null; } }
public List <UserEntity> Get() { List <UserEntity> list = new List <UserEntity>(); using (var db = new EventDBEntities()) { var records = db.UserMasters.Where(x => x.IsActive == true).ToList(); foreach (var item in records) { UserEntity userentity = new UserEntity(); userentity.Id = item.Id; userentity.Fullname = item.Fullname; UserTypeEntity usertypeentity = new UserTypeEntity(); if (item.UserTypeMaster != null) { usertypeentity.Id = item.UserTypeMaster.Id; usertypeentity.Usertype = item.UserTypeMaster.Usertype; userentity.UserTypeMaster = usertypeentity; } list.Add(userentity); } } return(list); }
// [Route("UserRights")] public ActionResult Index() { UserTypeEntity model = new UserTypeEntity(); var userTypeList = _userapicontroller.GetUserTypelist(); ViewBag.UserTypeId = new SelectList(userTypeList, "UserTypeId", "Name"); return(View(model)); }
public string UpdateUserType(UserTypeEntity usertypeDtl) { string strResponse = string.Empty; short UsTCurrentVersion = 0; try { var usertypeComponent = new UserTypeComponent(); var currentUserTypeDetails = usertypeComponent.GetUserTypeDetailByID(usertypeDtl.UsT_UserTypeID); int usertypeID = currentUserTypeDetails.UsT_UserTypeID; UsTCurrentVersion = Convert.ToInt16(currentUserTypeDetails.UsT_Version); bool UsTCurrentStatus = false; //check for version and active status if (ModelState["UsT_isDeleted"].Value != null) { //UsTCurrentStatus = (usertypeDtl.UsT_ActiveStatus == true) ? true : false; UsTCurrentStatus = usertypeDtl.UsT_isDeleted == true; } if (ModelState.IsValid) { UserSessionInfo _objSessioninfo = Session["UserSessionInfo"] as UserSessionInfo; int _userID = _objSessioninfo.UserId; usertypeDtl.UsT_ModifiedBy = _userID; //while udating increment version by1 usertypeDtl.UsT_Version = ++UsTCurrentVersion; usertypeDtl.UsT_isDeleted = UsTCurrentStatus; var Org = new UserTypeComponent(); int r = Org.UpdateUserTypeDetail(usertypeDtl); if (r == 1) { strResponse = "Employment type updated successfully"; } else if (r == 0) { strResponse = "Employment type already exists"; } else if (r == -1) { strResponse = "Error occured in UpdateUserType"; } else if (r == 2) { strResponse = "Employee Code Already Existed"; } else if (r == 3) { strResponse = "Employee Type Already Existed"; } } } catch (Exception ex) { return(strResponse); } return(strResponse); }
public PestForm(UserTypeEntity ut) { InitializeComponent(); this.ut = ut; lblPestDialog.Text = "Are you sure you want to delete usertype " + ut.Type + "?\n This cannot be undone."; btnPestYes.DialogResult = DialogResult.Yes; btnPestNo.DialogResult = DialogResult.No; }
public UserType ToDALModel(UserTypeEntity userType) { UserType userTypeDAL = new UserType() { Type = userType.Type, }; return(userTypeDAL); }
private void btnUTCrudDetails_Click(object sender, EventArgs e) { int userTypeIndex = dgvUTTable.CurrentCell.RowIndex; UserTypeEntity userType = AllUserTypes.ElementAt(userTypeIndex); CRUD_UserType crudUserType = new CRUD_UserType(userType); crudUserType.makeReadOnly(); crudUserType.Show(); }
public UserTypeEntity ToDomainModel(UserType userType) { UserTypeEntity userTypeDomain = new UserTypeEntity() { Id = userType.Id, Type = userType.Type }; return(userTypeDomain); }
private void btnUTCrudAdd_Click(object sender, EventArgs e) { UserTypeEntity ut = new UserTypeEntity(); CRUD_UserType crudUT = new CRUD_UserType(ut); crudUT.ShowDialog(); if (crudUT.DialogResult == DialogResult.OK) { AllUserTypes.Add(ut); dgvUTTable.Invalidate(); } }
public bool UpdateUserType(UserTypeEntity userType) { if (userType.UserTypeID > 0) { //update } else { //Insert } return(true); }
public bool UpdateUserType(UserTypeEntity userType) { if (userType.UserTypeID > 0) { //Update return(userTypeDAL.UpdateUserType(userType)); } else { //Insert return(userTypeDAL.InsertUserType(userType)); } }
private void btnUTCrudDelete_Click(object sender, EventArgs e) { int userTypeIndex = dgvUTTable.CurrentCell.RowIndex; UserTypeEntity userType = AllUserTypes.ElementAt(userTypeIndex); PestForm areYouSure = new PestForm(userType); areYouSure.ShowDialog(); if (areYouSure.DialogResult == DialogResult.Yes) { dgvUTTable.Rows.RemoveAt(userTypeIndex); dgvUTTable.Invalidate(); } }
public string CrudOperation(FormCollection formCollection) { string strResponse = string.Empty; try { var strOperation = formCollection["oper"]; if (strOperation == "add") { UserTypeEntity updateList = new UserTypeEntity { UsT_AccountID = Convert.ToInt32(formCollection.Get("UsT_AccountID")), UsT_UserTypeCode = formCollection.Get("UsT_UserTypeCode"), UsT_UserType = formCollection.Get("UsT_UserType"), UsT_UserTypeDescription = formCollection.Get("UsT_UserTypeDescription"), UsT_Version = 1, UsT_ActiveStatus = Convert.ToBoolean(formCollection.Get("UsT_ActiveStatus")), UsT_isDeleted = false }; strResponse = CreateUserType(updateList); } else if (strOperation == "edit") { UserTypeEntity updateList = new UserTypeEntity { UsT_UserTypeID = Convert.ToInt32(formCollection.Get("id")), UsT_AccountID = Convert.ToInt32(formCollection.Get("UsT_AccountID")), UsT_UserTypeCode = formCollection.Get("UsT_UserTypeCode"), UsT_UserType = formCollection.Get("UsT_UserType"), UsT_UserTypeDescription = formCollection.Get("UsT_UserTypeDescription"), //UsT_Version = Convert.ToInt16(formCollection.Get("UsT_Version")), UsT_ActiveStatus = Convert.ToBoolean(formCollection.Get("UsT_ActiveStatus")), UsT_isDeleted = Convert.ToBoolean(formCollection.Get("UsT_isDeleted")) }; strResponse = UpdateUserType(updateList); } else if (strOperation == "del") { int usertypeID = Convert.ToInt32(formCollection.Get("id")); strResponse = DeleteUserType(usertypeID); } } catch (Exception ex) { return(strResponse); } return(strResponse); }
public JsonResult GetUserTypeByID(int catID) { UserTypeEntity UserTypeDetails = null; try { var objDtl = new UserTypeComponent(); UserTypeDetails = objDtl.GetUserTypeDetailByID(catID); } catch (Exception ex) { return(null); } return(Json(UserTypeDetails, JsonRequestBehavior.AllowGet)); }
private void btnUTCrudEdit_Click(object sender, EventArgs e) { int userTypeIndex = dgvUTTable.CurrentCell.RowIndex; UserTypeEntity userType = AllUserTypes.ElementAt(userTypeIndex); CRUD_UserType crudUserType = new CRUD_UserType(userType); crudUserType.editing = true; crudUserType.ShowDialog(); if (crudUserType.DialogResult == DialogResult.OK) { dgvUTTable.InvalidateRow(userTypeIndex); } }
public async Task GetUserTypes() { var options = TestHelper.GetDbContext("GetUserTypes"); //Given var lkp1 = new UserTypeEntity { Id = Guid.NewGuid(), Name = "A", DisplayOrder = 1 }; var lkp2 = new UserTypeEntity { Id = Guid.NewGuid(), Name = "B", DisplayOrder = 2 }; var lkp3 = new UserTypeEntity { Id = Guid.NewGuid(), Name = "C", DisplayOrder = 3 }; using (var context = new DataContext(options)) { //Jumbled order context.UserType.Add(lkp2); context.UserType.Add(lkp1); context.UserType.Add(lkp3); context.SaveChanges(); } using (var context = new DataContext(options)) { var service = new DirectoryLookupService(context); //When var actual = await service.GetUserTypes(); //Then Assert.Equal(3, actual.Count); var actual1 = actual[0]; Assert.Equal(lkp1.Id, actual1.Id); Assert.Equal(lkp1.Name, actual1.Name); Assert.Equal(lkp1.DisplayOrder, actual1.DisplayOrder); var actual2 = actual[1]; Assert.Equal(lkp2.Id, actual2.Id); var actual3 = actual[2]; Assert.Equal(lkp3.Id, actual3.Id); } }
public int AddUserType(UserTypeEntity user) { int retVal = 0; UserType userType = new UserType(); UserType CodeCheck = new UserType(); using (var db = new DbContext(CONNECTION_NAME)) { try { userType = db.Set <UserType>().Where(s => (s.UsT_UserTypeID == user.UsT_UserTypeID)).FirstOrDefault <UserType>(); CodeCheck = db.Set <UserType>().Where(s => (s.UsT_UserTypeCode == user.UsT_UserTypeCode && s.UsT_AccountID == user.UsT_AccountID && s.UsT_isDeleted == false)).FirstOrDefault <UserType>(); UserType TypeCheck = db.Set <UserType>().Where(s => (s.UsT_UserType == user.UsT_UserType && s.UsT_AccountID == user.UsT_AccountID && s.UsT_isDeleted == false)).FirstOrDefault <UserType>(); if (CodeCheck != null) { return(retVal = 2); } if (TypeCheck != null) { return(retVal = 3); } if (userType != null) { return(retVal); } db.Set <UserType>().Add(new UserType { UsT_AccountID = user.UsT_AccountID, UsT_UserTypeCode = user.UsT_UserTypeCode, UsT_UserType = user.UsT_UserType, UsT_UserTypeDescription = user.UsT_UserTypeDescription, // UsT_ActiveStatus = user.UsT_ActiveStatus, UsT_Version = user.UsT_Version, UsT_CreatedBy = user.UsT_CreatedBy, UsT_CreatedDate = System.DateTime.Now, UsT_isDeleted = user.UsT_isDeleted }); db.SaveChanges(); retVal = 1; } catch (Exception ex) { retVal = -1; } } return(retVal); }
public CRUD_UserType(UserTypeEntity newUt) { InitializeComponent(); ut = newUt; btnUTCrudOK.DialogResult = DialogResult.None; btnUTCrudCancel.DialogResult = DialogResult.Cancel; #region Initialization if (ut.Id != 0) { tbUTCrudID.Text = ut.Id.ToString(); } else { tbUTCrudID.Text = ""; } tbUTCrudType.Text = ut.Type; #endregion }
public async Task <ResultEntity <UserTypeEntity> > Delete(UserTypeEntity entity) { ResultEntity <UserTypeEntity> result = new ResultEntity <UserTypeEntity>(); try { using (var context = dbContext) { context.UserTypeDBSet.Remove(entity); await context.SaveChangesAsync(); } } catch (Exception ex) { result.Status = StatusTypeEnum.Exception; result.MessageEnglish = ex.Message; result.DetailsEnglish = ex.StackTrace; } return(result); }
public string CreateUserType([Bind(Exclude = "UsT_UserTypeID")] UserTypeEntity usertypeDtl) { string strResponse = string.Empty; try { var usertypeComponent = new UserTypeComponent(); UserSessionInfo _objSessioninfo = Session["UserSessionInfo"] as UserSessionInfo; int _userID = _objSessioninfo.UserId; usertypeDtl.UsT_CreatedBy = _userID; var Org = new UserTypeComponent(); int r = Org.AddUserType(usertypeDtl); if (r == 1) { strResponse = "Employment type created successfully"; } else if (r == 0) { strResponse = "Employment type already exists"; } else if (r == -1) { strResponse = "Please Fill All Mandatory Fields"; } else if (r == 2) { strResponse = "Employee Code Already Existed"; } else if (r == 3) { strResponse = "Employee Type Already Existed"; } } catch (Exception ex) { return(strResponse); } return(strResponse); }
private UserEntity Map(UserMaster records) { UserEntity model = new UserEntity(); model.Id = records.Id; model.Fullname = records.Fullname; model.Username = records.Username; model.Usertypeid = records.Usertypeid; model.IsActive = records.IsActive; model.password = records.password; UserTypeEntity entity1 = new UserTypeEntity(); entity1.Id = (int)records.Usertypeid; entity1.Usertype = records.UserTypeMaster.Usertype; model.UserTypeMaster = entity1; return(model); }
public UserTypeEntity GetUserTypeDetailByID(int ID) { UserTypeEntity response = new UserTypeEntity(); using (var db = new EvolutyzCornerDataEntities()) { try { response = (from q in db.UserTypes join a in db.Accounts on q.UsT_AccountID equals a.Acc_AccountID where q.UsT_UserTypeID == ID select new UserTypeEntity { UsT_UserTypeID = q.UsT_UserTypeID, UsT_AccountID = q.UsT_AccountID, AccountName = a.Acc_AccountName, UsT_UserTypeCode = q.UsT_UserTypeCode, UsT_UserType = q.UsT_UserType, UsT_UserTypeDescription = q.UsT_UserTypeDescription, // UsT_ActiveStatus = q.UsT_ActiveStatus, UsT_Version = q.UsT_Version, UsT_CreatedBy = q.UsT_CreatedBy, UsT_CreatedDate = q.UsT_CreatedDate, UsT_ModifiedBy = q.UsT_ModifiedBy, UsT_ModifiedDate = q.UsT_ModifiedDate, UsT_isDeleted = q.UsT_isDeleted, }).FirstOrDefault(); response.IsSuccessful = true; return(response); } catch (Exception ex) { response.IsSuccessful = false; response.Message = "Error Occured in GetUserTypeDetailByID(ID)"; response.Detail = ex.Message.ToString(); return(response); } } }
public void Seed() { var ustype = new UserTypeEntity { ProjectId = 1, UserTypeName = "Guest" }; var ustype2 = new UserTypeEntity { ProjectId = 1, UserTypeName = "User" }; var ustype3 = new UserTypeEntity { ProjectId = 1, UserTypeName = "Administrator" }; var ustype4 = new UserTypeEntity { ProjectId = 2, UserTypeName = "Administrator" }; var ustype5 = new UserTypeEntity { ProjectId = 3, UserTypeName = "Project Developer" }; var ustype6 = new UserTypeEntity { ProjectId = 3, UserTypeName = "Project Leader" }; _session.Save(ustype); _session.Save(ustype2); _session.Save(ustype3); _session.Save(ustype4); _session.Save(ustype5); _session.Save(ustype6); }
public UserTypeEntity GetUserTypeByID(int userTypeID) { UserTypeEntity userType = new UserTypeEntity(); string strQry = "Select UserTypeID, UserTypeName, UserTypeDesc From tblUserType Where UserTypeID = @UserTypeID"; try { using (SqlConnection con = new SqlConnection(Connection.dbConnection)) { con.Open(); using (SqlCommand cmd = new SqlCommand(strQry, con)) { cmd.Parameters.AddWithValue("@UserTypeID", userTypeID); da.SelectCommand = cmd; da.Fill(dt); } } userType = dt.AsEnumerable().Select(item => new UserTypeEntity() { UserTypeID = Convert.ToInt32(item["UserTypeID"]), UserTypeName = Convert.ToString(item["UserTypeName"]), UserTypeDesc = Convert.ToString(item["userTypeDesc"]) }).FirstOrDefault(); return(userType); } catch (Exception ex) { return(new UserTypeEntity()); } finally { dt = null; userType = null; strQry = ""; } }
public bool InsertUserType(UserTypeEntity userTypeEntity) { try { using (SqlConnection con = new SqlConnection(Connection.dbConnection)) { con.Open(); using (SqlCommand cmd = new SqlCommand("usp_InsertUserType", con)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@UserTypeName", userTypeEntity.UserTypeName); cmd.Parameters.AddWithValue("@UserTypeDesc", userTypeEntity.UserTypeDesc == null ? "" : userTypeEntity.UserTypeDesc); cmd.Parameters.AddWithValue("@CreatedBy", userTypeEntity.CreatedBy); cmd.Parameters.AddWithValue("@CreatedOn", userTypeEntity.CreatedOn); cmd.Parameters.AddWithValue("@IsDeleted", userTypeEntity.IsDeleted); cmd.Parameters.Add("@UserTypeID", SqlDbType.Int); cmd.Parameters["@UserTypeID"].Direction = ParameterDirection.Output; cmd.ExecuteNonQuery(); int userTypeID = Convert.ToInt32(cmd.Parameters["@UserTypeID"].Value); if (userTypeID > 0) { return(true); } else { return(false); } } } } catch (Exception ex) { return(false); } }
public JsonResult AddUserType(UserTypeModel userTypeModel) { UserTypeEntity userTypeEntity = new UserTypeEntity(); userTypeEntity = AutoMapper.Mapper.Map <UserTypeModel, UserTypeEntity>(userTypeModel); bool status = userTypeBAL.UpdateUserType(userTypeEntity); if (status) { if (userTypeModel.UserTypeID > 0) { return(Json(new { Message = "User Type Updated Successfully..!", Status = status }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { Message = "User Type Added Successfully..!", Status = status }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { Message = "Operation Failed..!", Status = status }, JsonRequestBehavior.AllowGet)); } }
public int UpdateUserTypeDetail(UserTypeEntity _uesrtype) { var UserTypeDAC = new UserTypeDAC(); return(UserTypeDAC.UpdateUserTypeDetail(_uesrtype)); }
public int AddUserType(UserTypeEntity _uesrtype) { var UserTypeDAC = new UserTypeDAC(); return(UserTypeDAC.AddUserType(_uesrtype)); }
public int UpdateUserTypeDetail(UserTypeEntity userType) { UserType _userTypeDtl = null; History_UserType _userTypeHistory = new History_UserType(); int retVal = 0; using (var db = new DbContext(CONNECTION_NAME)) { try { _userTypeDtl = db.Set <UserType>().Where(s => s.UsT_UserTypeID == userType.UsT_UserTypeID).FirstOrDefault <UserType>(); UserType CodeCheck = db.Set <UserType>().Where(s => (s.UsT_UserTypeCode == userType.UsT_UserTypeCode && s.UsT_AccountID == userType.UsT_AccountID && s.UsT_isDeleted == false && s.UsT_UserTypeID != userType.UsT_UserTypeID)).FirstOrDefault <UserType>(); UserType TypeCheck = db.Set <UserType>().Where(s => (s.UsT_UserType == userType.UsT_UserType && s.UsT_AccountID == userType.UsT_AccountID && s.UsT_isDeleted == false && s.UsT_UserTypeID != userType.UsT_UserTypeID)).FirstOrDefault <UserType>(); if (CodeCheck != null) { return(retVal = 2); } if (TypeCheck != null) { return(retVal = 3); } if (_userTypeDtl == null) { return(retVal); } #region Saving History into History_UserType Table //check for _userTypeDtl.UsT_ModifiedDate as created date to history table DateTime dtAccCreatedDate = _userTypeDtl.UsT_ModifiedDate ?? DateTime.Now; db.Set <History_UserType>().Add(new History_UserType { History_UsT_UserTypeID = _userTypeDtl.UsT_UserTypeID, History_AccountID = _userTypeDtl.UsT_AccountID, History_UsT_UserTypeCode = _userTypeDtl.UsT_UserTypeCode, History_UsT_UserType = _userTypeDtl.UsT_UserType, History_UsT_UserTypeDescription = _userTypeDtl.UsT_UserTypeDescription, History_UsT_ActiveStatus = _userTypeDtl.UsT_ActiveStatus, History_UsT_Version = _userTypeDtl.UsT_Version, History_UsT_CreatedDate = dtAccCreatedDate, History_UsT_CreatedBy = _userTypeDtl.UsT_CreatedBy, History_UsT_ModifiedDate = _userTypeDtl.UsT_ModifiedDate, History_UsT_ModifiedBy = _userTypeDtl.UsT_ModifiedBy, History_UsT_isDeleted = _userTypeDtl.UsT_isDeleted }); #endregion #region Saving UserType info Table _userTypeDtl.UsT_AccountID = userType.UsT_AccountID; _userTypeDtl.UsT_UserTypeCode = userType.UsT_UserTypeCode; _userTypeDtl.UsT_UserType = userType.UsT_UserType; _userTypeDtl.UsT_UserTypeDescription = userType.UsT_UserTypeDescription; // _userTypeDtl.UsT_ActiveStatus = userType.UsT_ActiveStatus; _userTypeDtl.UsT_Version = userType.UsT_Version; _userTypeDtl.UsT_ModifiedDate = System.DateTime.Now; _userTypeDtl.UsT_ModifiedBy = userType.UsT_ModifiedBy; _userTypeDtl.UsT_isDeleted = userType.UsT_isDeleted; #endregion db.Entry(_userTypeDtl).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); retVal = 1; } catch (Exception ex) { retVal = -1; } return(retVal); } }