public IActionResult GetUserList(int _id) { try { var users = CompanyUserDB.GetInstance().GetUsersByCompanyId(_id); return(PartialView("_UserList", users)); } catch (Exception) { throw; } }
public override void OnActionExecuting(ActionExecutingContext filterContext) { if (HttpContext.Session.GetString("FrontSideActiveUser") == null) { filterContext.Result = new RedirectResult("/Login"); return; } userJson = HttpContext.Session.GetString("FrontSideActiveUser"); userObj = JsonConvert.DeserializeObject <User>(userJson); ViewBag.ActiveUser = userObj; ViewBag.CompanyUser = CompanyUserDB.GetInstance().GetCompanyUserByUserId(userObj.Id); base.OnActionExecuting(filterContext); }
public JsonResult ImportFile(string _excelData) { _excelData = HttpUtility.HtmlDecode(_excelData); var list2 = JsonConvert.DeserializeObject <List <CompanyExcelObject> >(_excelData); try { foreach (var item in list2) { Company company = new Company() { CompanyCode = item.SirketKodu, CompanyDescription = item.SirketKodu, MobileCount = item.MobilSayisi, Address1 = item.Adres1, Address2 = item.Adres2, Phone = item.Telefon, Fax = item.Fax, PersonInCharge = item.YetkiliKisi, CompanyPartnerId = !string.IsNullOrEmpty(item.IsOrtagi) ? CompanyPartnerDB.GetInstance().GetCompanyPartnerByNameOrInsert(item.IsOrtagi).Id : 0, DistributorId = DistributorDB.GetInstance().GetDistributorIdByName(item.BayiAdi), PlatformId = !string.IsNullOrEmpty(item.Platform) ? PlatformDB.GetInstance().GetPlatformByNameOrInsert(item.Platform).Id : 0, SectorId = !string.IsNullOrEmpty(item.Sektor) ? SectorDB.GetInstance().GetSectorByNameOrInsert(item.Sektor).Id : 0, LoginUrl = item.LoginUrl, BaseMap = item.BaseMap, TechnicalReport = item.TeknikRapor == "Aktif" ? true : false, TaxAdministration = item.VergiDairesi, TaxNumber = item.VergiNo, EntranceDate = GetExcelDateTime(item.GirisZamani), ExitDate = GetExcelDateTime(item.CikisZamani), AlarmSms = item.AlarmSms == "Aktif" ? true : false, PasswordControl = item.SifreKontrol == "Aktif" ? true : false, InfoSense = item.InfoSense == "Aktif" ? true : false, AccountingCode = item.MuhasebeHesKodu, Status = 1, CompanyStatus = true, CreationDate = DateTime.Now, UserStatus = true }; var companyAdmin = ConvertToEngStandarts(company.CompanyCode); bool isUserExist = UserDB.GetInstance().CheckIfUserExist(companyAdmin); if (isUserExist) { continue; } CompanyDB.GetInstance().AddNewCompany(company); if (!isUserExist) { if (companyAdmin != "") { User user = new User() { UserTypeId = 1, UserCode = companyAdmin, Password = "******", Status = 1 }; UserDB.GetInstance().AddNewUser(user); CompanyUser companyUser = new CompanyUser() { CompanyId = company.Id, IsCompanyAdmin = true, Status = 1, UserId = user.Id }; CompanyUserDB.GetInstance().AddNewCompanyUser(companyUser); } } } return(Json(true)); } catch (Exception exc) { throw exc; } }
public JsonResult SaveCompany(int _id, int _mainCompanyId, int _companyTypeId, int _companyPartnerId, int _platformId, int _distributorId, int _sectorId, int _companyReportId, string _companyCode, string _companyDescription, string _address1, string _phone, string _userName, string _userSurname, string _userPhone, string _userEmail, bool _technicalReport, string _technicalEmail1, string _technicalEmail2, string _technicalEmail3, bool _companyStatus, bool _alarmSms, bool _passwordControl, string _userCode, string _userPassword, bool _userStatus, bool _companyVehicleProgramming, string _companyGroupName, int _userId, string _accountingCode) { try { if (_id == 0) { var user = new User() { Name = _userName, Surname = _userSurname, UserCode = _userCode, Mail = _userEmail, Password = _userPassword, Telephone = _userPhone, Status = 1, UserTypeId = 1, GeographicalAuthorityId = 1, HomepageRefreshTime = 60000 }; UserDB.GetInstance().AddNewUser(user); Company company = new Company() { MainCompanyId = _mainCompanyId, CompanyTypeId = _companyTypeId, CompanyPartnerId = _companyPartnerId, PlatformId = _platformId, DistributorId = _distributorId, SectorId = _sectorId, CompanyReportId = _companyReportId, CompanyCode = _companyCode, CompanyDescription = _companyDescription, Address1 = _address1, Phone = _phone, TechnicalReport = _technicalReport, TechnicalEmail1 = _technicalEmail1, TechnicalEmail2 = _technicalEmail2, TechnicalEmail3 = _technicalEmail3, CompanyStatus = _companyStatus, AlarmSms = _alarmSms, PasswordControl = _passwordControl, CompanyVehicleProgramming = _companyVehicleProgramming, CompanyGroupName = _companyGroupName, CreationDate = DateTime.Now, Status = 1, UserStatus = _userStatus, AccountingCode = _accountingCode }; var result = CompanyDB.GetInstance().AddNewCompany(company); CompanyUser compUser = new CompanyUser() { IsCompanyAdmin = true, UserId = user.Id, Status = 1, CompanyId = company.Id }; CompanyUserDB.GetInstance().AddNewCompanyUser(compUser); return(Json(result != null)); } else { var user = UserDB.GetInstance().GetUserById(_userId); user.Name = _userName; user.Surname = _userSurname; user.UserCode = _userCode; user.Mail = _userEmail; user.Telephone = _userPhone; var isPasswordGoingToBeDifferent = 0; if (user.Password.Trim().ToLower() == _userPassword.Trim().ToLower()) { isPasswordGoingToBeDifferent = 0; } if (user.Password.Trim().ToLower() != _userPassword.Trim().ToLower()) { user.Password = _userPassword; isPasswordGoingToBeDifferent = 1; } UserDB.GetInstance().UpdateUser(user, isPasswordGoingToBeDifferent); Company company = new Company() { Id = _id, MainCompanyId = _mainCompanyId, CompanyTypeId = _companyTypeId, CompanyPartnerId = _companyPartnerId, PlatformId = _platformId, DistributorId = _distributorId, SectorId = _sectorId, CompanyReportId = _companyReportId, CompanyCode = _companyCode, CompanyDescription = _companyDescription, Address1 = _address1, Phone = _phone, TechnicalReport = _technicalReport, TechnicalEmail1 = _technicalEmail1, TechnicalEmail2 = _technicalEmail2, TechnicalEmail3 = _technicalEmail3, CompanyStatus = _companyStatus, AlarmSms = _alarmSms, PasswordControl = _passwordControl, CompanyVehicleProgramming = _companyVehicleProgramming, CompanyGroupName = _companyGroupName, CreationDate = DateTime.Now, Status = 1, UserStatus = _userStatus, AccountingCode = _accountingCode }; var result = CompanyDB.GetInstance().UpdateCompany(company); return(Json(result != null)); } } catch (Exception exc) { throw exc; } }
public JsonResult SaveUser(int _compUserUserId, string _compUserUserCode, string _compUserName, string _compUserSurname, string _compUserTelephone, string _compUserMail, string _compUserpassword, int _compUserstatus, int _companyIdForSavingUser) { try { using (var context = new VeraEntities()) { if (_compUserUserId == 0) { User user = new User() { Name = _compUserName, Surname = _compUserSurname, Telephone = _compUserTelephone, Mail = _compUserMail, UserCode = _compUserUserCode, UserTypeId = 1, Password = _compUserpassword, Status = 1 }; var result = UserDB.GetInstance().AddNewUser(user); CompanyUser compUser = new CompanyUser() { CompanyId = _companyIdForSavingUser, UserId = user.Id, IsCompanyAdmin = true, Status = 1 }; CompanyUserDB.GetInstance().AddNewCompanyUser(compUser); return(Json(result != null)); } else { var userToUpdate = new User() { Id = _compUserUserId, Name = _compUserName, Surname = _compUserSurname, Telephone = _compUserTelephone, Mail = _compUserMail, UserCode = _compUserUserCode, UserTypeId = 1, Password = _compUserpassword, Status = 1 }; var userTUpdate = UserDB.GetInstance().GetUserById(_compUserUserId); var isPasswordGoingToBeDifferent = 0; if (userTUpdate.Password.Trim().ToLower() == _compUserpassword.Trim().ToLower()) { isPasswordGoingToBeDifferent = 0; } if (userTUpdate.Password.Trim().ToLower() != _compUserpassword.Trim().ToLower()) { userToUpdate.Password = _compUserpassword; isPasswordGoingToBeDifferent = 1; } var result = UserDB.GetInstance().UpdateUser(userToUpdate, isPasswordGoingToBeDifferent); return(Json(result != null)); } } } catch (Exception exc) { return(Json(false)); throw exc; } }