public static void EditUserType(CMSDatabase db, int?itemID, UserTypeModel model, HttpContext context, out bool successfullyCompleted) { if (string.IsNullOrEmpty(model.Name) || !model.AccessLevel.HasValue || !itemID.HasValue || !Enum.IsDefined(typeof(AccessLevel), model.AccessLevel.Value)) { successfullyCompleted = false; return; } UserType userType = db.UserTypes.FirstOrDefault(ut => ut.ID == itemID.Value); if (userType == null || (userType.ID == 1 && model.AccessLevel.Value != userType.AccessLevel)) { successfullyCompleted = false; return; } string oldName = userType.Name; AccessLevel oldAccessLevel = userType.AccessLevel; userType.Name = model.Name; userType.AccessLevel = model.AccessLevel.Value; db.SaveChanges(); successfullyCompleted = true; LogManagementFunctions.AddAdminPanelLog( db: db, context: context, info: $"{oldName} ({oldAccessLevel.ToString()}) -> {userType.Name} ({userType.AccessLevel.ToString()}): {(context.Items["LogLocalization"] as IAdminPanelLogLocalization)?.UserTypeEdited}" ); }
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 ActionResult SignUp() { List <SelectListItem> l = UserTypeModel.Types(); ViewBag.t = l; return(View()); }
public HttpResponseMessage GetUserTypes(UserTypeModel model) { IUnitOfWork uWork = new UnitOfWork(); IUserTypeRepository repo = new UserTypeRepository(uWork); IUserTypeService userTypeService = new UserTypeService(repo); try { if (this.ModelState.IsValid) { var userTypeList = userTypeService.GetAllUserTypeList(model); if (userTypeList != null) { return(Request.CreateResponse(HttpStatusCode.OK, userTypeList)); } else { string message = "Error in getting Data"; return(Request.CreateErrorResponse(HttpStatusCode.Forbidden, message)); } } else { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.InnerException.Message)); } }
public PartialViewResult UserTypePartial(int?id) { var oModel = new UserTypeModel(); if (id != 0) { oModel.OUserType.Id = Convert.ToInt32(id); if (oModel.OUserType.Id > 0) { var oResult = _db.UserTypes.First(x => x.Id == oModel.OUserType.Id); if (oResult != null) { oModel.OUserType = oResult; } else { Response.Redirect("/Error/Error"); } } } else { oModel.OUserType = new UserType(); } return(PartialView("UserParts/_UserAddEditType", oModel)); }
public ActionResult ViewUserType() { UserTypeModel userType = new UserTypeModel(); userType.UserTypeList = ApplicationHelper.GetUserTypesList(); return(View(userType)); }
public IActionResult Index() { var x = new UserTypeModel { }; return(View(x)); }
public IActionResult AddUserType(int userTypeId, string operationType) { var model = new UserTypeModel(userTypeId, operationType, _userTypeService); _session.SetString("OperationType", operationType); return(PartialView("_AddUserType", model)); }
public UserType Bind(UserTypeModel userTypeModel) { UserType userType = new UserType(); userType.Id = userTypeModel.Id; userType.UserTypeCode = userTypeModel.UserTypeCode; return(userType); }
public async Task <IActionResult> AddUserType(UserTypeModel model) { try { var OperationType = _session.GetString("OperationType"); var userType = new UserType(); string mesaj = ""; //Yeni Kayıt İse ekle if (OperationType == Constants.OperationType.Insert) { #region UserType Sistemde Var Mı Kontrolü userType = await _userTypeService.SingleOrDefaultAsync(x => x.Name == model.Name || x.Code == model.Code && x.IsDeleted == false); if (userType != null) { return(Json(new JsonMessage { HataMi = true, Baslik = "İşlem Başarısız", Mesaj = "Eklemek istediğiniz özelliklere sahip userType sistemde zaten mevcut." })); } #endregion #region UserType Ekle userType = new UserType { Name = model.Name, Code = model.Code, IsDeleted = false }; await _userTypeService.AddAsync(userType); mesaj = "Yeni UserType Başarıyle Eklendi."; #endregion } if (OperationType == Constants.OperationType.Update) { #region Update İşlemi userType = await _userTypeService.GetByIdAsync(model.Id); userType.Name = model.Name; userType.Code = model.Code; _userTypeService.Update(userType); mesaj = "Yeni UserType Başarıyle Güncellendi."; #endregion } return(Json(new JsonMessage { HataMi = false, Baslik = "İşlem Başarılı", Mesaj = mesaj })); } catch (Exception ex) { return(Json(new JsonMessage { HataMi = true, Baslik = "İşlem Başarısız", Mesaj = "İşlem Sırasında Hata Oluştu." })); } }
public ActionResult Edit([Bind(Include = "Id,UserTypeCode")] UserTypeModel userTypeModel) { if (ModelState.IsValid) { db.Entry(userTypeModel).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(userTypeModel)); }
public ActionResult NewUser(UserTypeModel model) { #region ErrorMessages InsertError errLog = TempData["errorLog"] as InsertError; if (errLog != null) { ViewData["ErrorMessageLog"] = errLog.ErrorMessageLog; } InsertError errPass = TempData["errorPassword"] as InsertError; if (errPass != null) { ViewData["ErrorMessagePassword"] = errPass.ErrorMessagePassword; } InsertError errNotStrongPass = TempData["errorNotStrongPassword"] as InsertError; if (errNotStrongPass != null) { ViewData["ErrorMessageNotStrongPassword"] = errNotStrongPass.ErrorMessageNotStrongPassword; } InsertError errEmptyConfirmPass = TempData["errorEmptyConfirmPassword"] as InsertError; if (errEmptyConfirmPass != null) { ViewData["ErrorMessageEmptyConfirmPassword"] = errEmptyConfirmPass.ErrorMessageEmptyConfirmPassword; } InsertError errConfirmPass = TempData["errorConfirmPassword"] as InsertError; if (errConfirmPass != null) { ViewData["ErrorMessageConfirmPassword"] = errConfirmPass.ErrorMessageConfirmPassword; } InsertError errEmptyUserType = TempData["errorEmptyUserType"] as InsertError; if (errEmptyUserType != null) { ViewData["ErrorMessageEmptyUserType"] = errEmptyUserType.ErrorMessageEmptyUserType; } #endregion using (var context = new WHOLESALE_STOREEntities()) { foreach (var usertype in context.USERTYPE.ToList()) { model.UserTypes.Add(new UserType() { Name = usertype.NAME, Id = usertype.ID }); } } return(View("~/Views/User/NewUser.cshtml", model)); }
public ActionResult UpdateType(UserTypeModel model) { var type = new UserTypeDto { AwayTeamGoals = model.AwayTeamGoals, HomeTeamGoals = model.HomeTeamGoals, UserId = model.UserId }; userBetsService.UpdateType(type); return(Ok()); }
public static UserTypeModel CreateUserContactInfo(UserTypeModel userTypeModel) { using (var _context = new bbbsDbContext()) { var newUserType = _context.Add(new UserType { UserTypeName = userTypeModel.UserTypeName }); _context.SaveChanges(); userTypeModel.Id = newUserType.Entity.Id; return(userTypeModel); } }
public int AddEditUserType(UserTypeModel objmodel) { try { return(objroledal.AddEditUserType(objmodel)); } catch (Exception) { return(0); throw; } }
public ActionResult Create([Bind(Include = "Id,UserTypeCode")] UserTypeModel userTypeModel) { if (ModelState.IsValid) { UserTypeBinder userTypeBinder = new UserTypeBinder(); UserType userType = userTypeBinder.Bind(userTypeModel); db.UserType.Add(userType); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(userTypeModel)); }
public async Task <ResultEntity <UserTypeModel> > Update(UserTypeModel entity) { ResultEntity <UserTypeModel> result = new ResultEntity <UserTypeModel>(); try { result = _mapper.Map <ResultEntity <UserTypeModel> >(await _userTypeRepository.Update(_mapper.Map <UserTypeEntity>(entity))); } catch (Exception ex) { result.Status = StatusTypeEnum.Exception; result.MessageEnglish = ex.Message; result.DetailsEnglish = ex.StackTrace; } return(result); }
public JsonResult Save([Bind(Include = "Id, Name, Description, IsActive")] UserTypeModel userType, bool isInsert) { if (isInsert) { userType.SetCreateProperties(LoginInformation.UserInformation.Id); userType.Id = _userTypeService.Insert(userType); } else { userType.SetUpdateProperties(LoginInformation.UserInformation.Id); _userTypeService.Update(userType); } return(new JsonResult { Data = userType }); }
public String getUserType(string emailID) { UserTypeModel userTypeModel = new UserTypeModel(); DataTable dtblProfile = new DataTable(); using (SqlConnection sqlCon = new SqlConnection(connectionString)) { sqlCon.Open(); string query = "SELECT UTID FROM Users where EmailID =@EmailID"; SqlDataAdapter sqlDa = new SqlDataAdapter(query, sqlCon); sqlDa.SelectCommand.Parameters.AddWithValue("@EmailID", emailID); sqlDa.Fill(dtblProfile); } String UserType = dtblProfile.Rows[0][0].ToString(); return(UserType); }
/// <summary> /// Creates a new user account /// </summary> /// <param name="us"></param> /// <param name="t"></param> /// <returns></returns> public ActionResult CreateUser(UserModel us, string t) { List <SelectListItem> l = UserTypeModel.Types(); us.TypeId = Convert.ToInt32(t); bool tmpbool = UserModel.RegisterUser(us); if (tmpbool) { return(RedirectToAction("Login", "Login")); } else { ViewBag.t = l; return(View("SignUp", us)); } }
public ActionResult CheckEmail(string t) { List <SelectListItem> l = UserTypeModel.Types(); UserModel us = new UserModel(); us.Email = t; bool tmpbool = UserModel.CheckExistingUser(us); if (tmpbool) { return(Json(true)); } else { return(Json(false)); } }
void loadUserType() { String query = "SELECT * FROM tbl_usertype"; MySqlConnection databaseConnection = new MySqlConnection(connectionString); MySqlCommand databaseCommand = new MySqlCommand(query, databaseConnection); databaseCommand.CommandTimeout = 60; MySqlDataReader reader; try { databaseConnection.Open(); reader = databaseCommand.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { if (LoginModel.userRights == "SuperUser") { UserTypeModel tmp = new UserTypeModel { userType = reader.GetString(0) }; cbUserType.Items.Add(tmp.userType); } else { UserTypeModel tmp = new UserTypeModel { userType = reader.GetString(0) }; if (tmp.userType != "SuperAdmin") { cbUserType.Items.Add(tmp.userType); } } } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public static async Task <UserTypeModel> UserTypeResult(string url) { UserTypeModel objData = new UserTypeModel(); try { using (var client = new HttpClient()) { client.BaseAddress = new Uri(url); var result = await client.GetAsync(url); var place = result.Content.ReadAsStringAsync().Result; objData = JsonConvert.DeserializeObject <UserTypeModel>(await result.Content.ReadAsStringAsync()); } } catch (Exception ex) { } return(objData); }
public ICollection <UserTypeModel> Bind(ICollection <UserType> userType) { ICollection <UserTypeModel> userTypeModelList = new List <UserTypeModel>(); try { foreach (var item in userType) { UserTypeModel userTypeModel = new UserTypeModel(); userTypeModel.Id = item.Id; userTypeModel.UserTypeCode = item.UserTypeCode; userTypeModelList.Add(userTypeModel); } } catch (Exception ex) { Console.WriteLine(ex.Message); } return(userTypeModelList); }
public static void AddUserType(CMSDatabase db, UserTypeModel model, HttpContext context, out bool successfullyCompleted) { if (string.IsNullOrEmpty(model.Name) || !model.AccessLevel.HasValue || !Enum.IsDefined(typeof(AccessLevel), model.AccessLevel.Value)) { successfullyCompleted = false; return; } UserType userType = new UserType { Name = model.Name, AccessLevel = model.AccessLevel.Value }; db.UserTypes.Add(userType); db.SaveChanges(); successfullyCompleted = true; LogManagementFunctions.AddAdminPanelLog( db: db, context: context, info: $"{userType.Name} ({userType.AccessLevel.ToString()}): {(context.Items["LogLocalization"] as IAdminPanelLogLocalization)?.UserTypeAdded}" ); }
public ActionResult ValidateUser(UserModel u) { if (UserAuthentication.CheckUser(u)) { string s; s = Session.SessionID; Session["user"] = u; UserModel.AddSessionId(s); List <UserTypeModel> l = UserTypeModel.GetUserType();; //var url = Url.RouteUrl("ActionApi", new { controller = "Home", action = "Get" }); //return RedirectToAction("Get", "Home", Url.RouteUrl("ActionApi", new { controller = "Home" })); return(RedirectToAction("Home", "Home")); } else { //ModelState.AddModelError("", "The user name or password provided is incorrect."); return(View("Login", u)); } }
public ActionResult AddUserType(UserTypeModel userType) { string sFunctionName = "AddUserType()"; ResponseModel Result = new ResponseModel(); try { Result = userType.AddUserType(userType.UserTypeName); if (Result.isSuccessful) { return(Json(new { success = true, ResponseMessage = "User Type \"" + userType.UserTypeName + "\" Successfully Added." })); //return RedirectToAction(Constants.WebPageAction.AddUserTypeDone, Constants.WebPageController.UserManagement, userType); } else { return(Json(new { success = true, ResponseMessage = "User Type \"" + userType.UserTypeName + "\" Already exist." })); //return RedirectToAction(Constants.WebPageAction.Index, Constants.WebPageController.Error); } } catch (Exception ex) { Result.FailedWithException(); return(Json(new { success = true, ResponseMessage = "User Type \"" + userType.UserTypeName + "\" Failed to Add." })); } }
public int AddEditUserType(UserTypeModel objmodel) { try { if (objmodel.UserTypeId != 0) { var objrole = objdb.UserTypes.Find(objmodel.UserTypeId); objrole.UserTypeName = objmodel.UserTypeName; objrole.UserTypeId = objmodel.UserTypeId; //objrole.UpdatedBy = objmodel.UpdatedBy; objrole.UpdatedDate = DateTime.Now; objrole.IsActive = objmodel.IsActive; objdb.SaveChanges(); return(objmodel.UserTypeId); } else { UserType objrole = new UserType { IsActive = objmodel.IsActive, UserTypeName = objmodel.UserTypeName, // CreatedBy = objmodel.CreatedBy, CreatedDate = DateTime.Now, }; objdb.UserTypes.Add(objrole); objdb.SaveChanges(); return(objrole.UserTypeId); } } catch (Exception) { return(0); throw; } }
public ActionResult DeleteUserType(UserTypeModel userType) { string sFunctionName = "DeleteUserType()"; ResponseModel Result = new ResponseModel(); Result.FailedWithoutException(); try { Result = userType.DeleteUserType(); if (Result.isSuccessful) { return(Json(new { UserTypeList = JsonConvert.SerializeObject(userType.UserTypeList), ResponseMessage = "Successfully deleted the " + userType.UserTypeName + " User Type.", success = true })); } else { return(Json(new { ResponseMessage = "Failed to delete the " + userType.UserTypeName + " User Type.", success = false })); } } catch (Exception ex) { return(Json(new { ResponseMessage = "Failed to delete the " + userType.UserTypeName + " User Type. Please try again later.", success = 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)); } }