public ActionResult SearchCompanies(int cityId = -1, int districtId = -1, int page = 1) { var model = new AgencyModel(); int pageSize = WebRealty.Common.PagingHelper.GetPageSize(); model.Agencies = new AgencyRoutines(this._db).GetAgency(cityId, districtId, page, pageSize).ToList<Agency>(); //model.Phones = new AgencyToPhoneRoutines(this._db).GetPhonesByAgencyId(model.Agencies).ToList<AgencyToPhone>(); return View(model); }
public int Create(AgencyModel model, List <AgentBankModel> AgentBankModel, int[] ChkProductId, FormCollection fc) { int AgentId = 0; AgentId = SaveAgent(model); model.AgentId = AgentId; CreateAgentUser(model, (int)ATLTravelPortal.Helpers.UserTypes.User); List <int> ChkProductIdS = new List <int>(); foreach (int pid in ChkProductId) { ChkProductIdS.Add(pid); model.AgentRole = "Ticketing Agent"; Roles.AddUserToRole(model.UserName, model.AgentRole); } AddAgentProduct(ChkProductIdS, AgentId); MembershipUser mem = Membership.GetUser(model.UserName); Guid userGUId = new Guid(mem.ProviderUserKey.ToString()); if (model.AgentStatusid == 0) { pro.LockUserNow(model.UserName); Membership.UpdateUser(mem); } int AppUserId = GetUserDetails(userGUId); AddUserProduct(ChkProductIdS, AppUserId); if (ChkProductIdS.Contains(1)) { SaveAgentGeneralLedger(AgentId, 1, model.CreatedBy); } SaveAgentCoreConfiguration(AgentId, model.Email); if (model.MasterDealIdOfAirlines != 0) { SaveAgentDeal(model, AgentId, 1); } return(AgentId); }
// GET: Agency/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } AgencyModel agency = db.Agencies.Find(id); if (agency == null) { return(HttpNotFound()); } return(View(agency)); }
public ActionResult Index(AgencyModel model) { try { int currentPageIndex = 1; int defaultPageSize = 30; model.AgencyList = ser.GetSignUpAgentSearchResult(model.AgencyName.Trim()).ToPagedList(currentPageIndex, defaultPageSize); return(View(model)); } catch { return(RedirectToAction("Index")); } }
private ActionResponse CreateAgentUser(AgencyModel model, int p) { UserManagementModel.CreateAspUser obj = new UserManagementModel.CreateAspUser(); obj.UserName = model.UserName; obj.Password = model.Password; obj.Email = model.Email; obj.FullName = model.FullName; obj.Address = model.Address; obj.MobileNo = model.Mobile; obj.PhoneNo = model.Phone; obj.AgentId = model.AgentId; obj.CreatedBy = model.CreatedBy; _usRep.CreateUser(obj, (int)ATLTravelPortal.Helpers.UserTypes.User); return(_res); }
public ActionResult Create() { var types = GetAllTypes(); var hospitals = GetAllHospitals(); var polices = GetAllPoliceDepartments(); var fires = GetAllFireStations(); var model = new AgencyModel(); model.Types = GetSelectListItems(types); model.Hospitals = GetSelectListItems(hospitals); model.PoliceDepartments = GetSelectListItems(polices); model.FireStations = GetSelectListItems(fires); return(View(model)); }
public static int CreateAgency(int agencyID, string agencyName, bool agencyStatus, DateTime agencyDateCreated, DateTime agencyDateLastEdited) { AgencyModel data = new AgencyModel { AgencyID = agencyID, AgencyName = agencyName, AgencyStatus = agencyStatus, AgencyDateCreated = agencyDateCreated, AgencyDateLastEdited = agencyDateLastEdited }; //sql for sending data to the database from the values above string sql = @"INSERT INTO Agency (agencyid, agencyname, agencystatus, agencydatecreated, agencydatelastedited) VALUES (@AgencyID, @AgencyName, @AgencyStatus, @AgencyDateCreated, @AgencyDateLastEdited);"; return(SQLDataAccess.SaveData(sql, data)); }
/// <summary> /// Get all the agencies, 10 per page and ability to search on agency name /// </summary> /// <param name="page"></param> /// <param name="agencyName"></param> /// <returns></returns> public ActionResult AllAgencies(int?page, string agencyName) { List <AgencyModel> agencyModels = new List <AgencyModel>(); using (var context = new lifeflightapps()) { if (!string.IsNullOrEmpty(agencyName)) { string[] agencyDetails = agencyName.Split('-'); string name = agencyDetails[0].Trim(); string city = agencyDetails[1].Trim(); string state = agencyDetails[2].Trim(); var agencyQueried = context.tblEmsAgencyLocals.FirstOrDefault(c => c.Name == name && c.City == city && c.State == state); if (agencyQueried != null) { return(RedirectToAction("GetAgencyDetails", new { agencyId = agencyQueried.EMSID })); } } var agencies = context.tblEmsAgencyLocals.ToList(); foreach (var agency in agencies) { AgencyModel model = new AgencyModel() { AddressLn1 = agency.Address, AddressLn2 = agency.Address2, LocalUse = agency.LocalUse, AgencyId = agency.EMSID, AgencyName = agency.Name, City = agency.City, StateCode = agency.State, Zip = agency.Zip, Phone = agency.Phones, AgencyType = agency.Type, County = agency.County }; agencyModels.Add(model); } } int pageSize = 10; int pageNumber = (page ?? 1); return(View(agencyModels.OrderBy(x => x.AgencyName).ToPagedList(pageNumber, pageSize))); }
public static int EditAgency(int agencyID, string agencyName, bool agencyStatus, DateTime agencyDateCreated, DateTime agencyDateLastEdited) { AgencyModel data = new AgencyModel { AgencyID = agencyID, AgencyName = agencyName, AgencyStatus = agencyStatus, AgencyDateCreated = agencyDateCreated, AgencyDateLastEdited = agencyDateLastEdited }; string sql = @"UPDATE Agency SET agencyid = @AgencyID, agencyname = @AgencyName, agencystatus = @AgencyStatus, agencydatecreated = @AgencyDateCreated, agencydatelastedited = @AgencyDateLastEdited WHERE agencyid = @AgencyID;"; return(SQLDataAccess.SaveData(sql, data)); }
public static bool DeleteAgency(AgencyModel model) { DataSet ds = new DataSet(); using (IDbConnection connection = OpenConnection()) { var p = new DynamicParameters(); p.Add("@CultureId", model.CultureId); p.Add("@id", model.Id); p.Add("@Code", model.Code, DbType.Int32, ParameterDirection.Output); p.Add("@Message", model.Message, DbType.String, ParameterDirection.Output); var success = connection.Query <bool>("usp_Delete_Agency_General", p, commandType: CommandType.StoredProcedure).First(); return(success); } }
public void Create(AgencyModel model, out Guid agencyId) { var companyId = this.GetCurrentCompanyId(); if (this._repoAgency.Query().Filter(x => x.code == model.code && x.companyId == companyId).Get().Any()) { throw new Exception(model.code + " is already exists"); } var userId = this.GetCurrentUserId(); var ins = this._repoAgency.Insert(new mf_Agency() { companyId = companyId, code = model.code, description = model.description, updatedBy = userId, }); this._unitOfWork.Save(); agencyId = ins.id; }
public ActionResult EditAgencyDetails(AgencyModel agency) { if (ModelState.IsValid) { tblEmsAgencyLocal dbAgencyLocal = new tblEmsAgencyLocal() { EMSID = agency.AgencyId, Address = agency.AddressLn1, Address2 = agency.AddressLn2, City = agency.City, State = agency.StateCode, Name = agency.AgencyName, LocalUse = agency.LocalUse, Type = agency.AgencyType, Zip = agency.Zip, County = agency.County, Phones = agency.Phone, BaseRate = agency.BaseRate, MileageRate = agency.MileageRate, taxID = agency.TaxId.ToString() }; try { using (var context = new lifeflightapps()) { context.tblEmsAgencyLocals.AddOrUpdate(dbAgencyLocal); context.SaveChanges(); } return(RedirectToAction("GetAgencyDetails", new { agencyId = agency.AgencyId })); } catch (DataException dx) { ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists, see your system administrator."); throw dx; } } else { return(View(agency)); } }
public ActionResult Create([Bind(Include = "Id,Type,Name,Address,Latitude,Longitude,Description,WebsiteUrl,Contact,Email")] AgencyModel model) { var types = GetAllTypes(); var hospitals = GetAllHospitals(); var polices = GetAllPoliceDepartments(); var fires = GetAllFireStations(); model.Types = GetSelectListItems(types); model.Hospitals = GetSelectListItems(hospitals); model.PoliceDepartments = GetSelectListItems(polices); model.FireStations = GetSelectListItems(fires); if (ModelState.IsValid) { db.Agencies.Add(model); db.SaveChanges(); return(RedirectToAction("SaveToFirebase", new { aid = model.Id })); } return(View(model)); }
public int SaveAgent(AgencyModel modelTosave) { int AgentId = 0; Agents datamodel = new Agents { AgentName = modelTosave.AgencyName, NativeCountry = 1, ZoneId = modelTosave.State, Address = modelTosave.Address, DistrictId = modelTosave.City, Phone = modelTosave.Phone, Email = modelTosave.Email, FaxNo = modelTosave.FaxNo, Web = modelTosave.Web, PanNo = modelTosave.PanCardNo, AgentStatus = false, AgentTypeId = 1, // AgentCode = modelTosave.AgentCode, AgentClassId = null, AirlineGroupId = 1, MaxNumberOfAgentUser = -1, AgentLogo = modelTosave.AgentLogo, CreatedBy = modelTosave.CreatedBy, CreatedDate = modelTosave.CreatedDate, TimeZoneId = modelTosave.TimeZoneId, DistributorId = 1, BranchOfficeId = 1 }; ent.AddToAgents(datamodel); ent.SaveChanges(); AgentId = datamodel.AgentId; _res.ErrNumber = 0; string AgentCode = UpdateAgentCode(AgentId); return(AgentId); }
public void SaveAgentDeal(AgencyModel modelTosave, int agentid, int ProductId) { Core_AgentsDeals datamodel = new Core_AgentsDeals(); datamodel.AgentId = agentid; datamodel.ProductId = ProductId; if (ProductId == 1) { datamodel.MasterDealId = modelTosave.MasterDealIdOfAirlines; } else if (ProductId == 2) { datamodel.MasterDealId = modelTosave.MasterDealIdOfHotel; } datamodel.CreatedBy = modelTosave.CreatedBy; datamodel.CreatedDate = modelTosave.CreatedDate; ent.AddToCore_AgentsDeals(datamodel); ent.SaveChanges(); }
public static IEnumerable <AgencyModel> GetAgency(AgencyModel model) { DataSet ds = new DataSet(); using (IDbConnection connection = OpenConnection()) { var p = new DynamicParameters(); p.Add("@CultureId", model.CultureId); p.Add("@id", model.Id); p.Add("@Code", model.Code, DbType.Int32, ParameterDirection.Output); p.Add("@Message", model.Message, DbType.String, ParameterDirection.Output); var result = connection.Query <AgencyModel>("usp_GetAgency_General", p, commandType: CommandType.StoredProcedure).ToList(); if (result != null && result.Count() > 0) { return(result); } } return(null); }
public void Update(AgencyModel model) { var upt = this._repoAgency.Find(model.id); if (upt.code != model.code) { var companyId = this.GetCurrentCompanyId(); if (this._repoAgency.Query().Filter(x => x.code == model.code && x.companyId == companyId).Get().Any()) { throw new Exception(model.code + " is already exists"); } upt.code = model.code; } var userId = this.GetCurrentUserId(); upt.description = model.description; upt.updatedBy = userId; upt.updatedDate = DateTime.Now; this._repoAgency.Update(upt); this._unitOfWork.Save(); }
// POST api/values public HttpResponseMessage Post(AgencyModel model) { if (HttpContext.Current.Request.Headers["Authorization"] == null) { throw new HttpResponseException(HttpStatusCode.Unauthorized); } string token = HttpContext.Current.Request.Headers["Authorization"]; AGENCY objBdd = new AGENCY(); objBdd.NAME = model.Name; objBdd.LATITUDE = model.Latitude; objBdd.LONGITUDE = model.Longitude; manager.add(objBdd); return(new HttpResponseMessage() { Content = new JsonContent(new { Success = true, //error Message = "Success" //return exception }) }); }
public ActionResult AgencyCRUD([DataSourceRequest] DataSourceRequest request , UpdateType updateType , AgencyModel model) { if (model != null && ModelState.IsValid) { try { switch (updateType) { case UpdateType.Create: Guid agencyId; this._agencyService.Create(model, out agencyId); model.id = agencyId; break; case UpdateType.Update: this._agencyService.Update(model); break; case UpdateType.Destroy: this._agencyService.Delete(model.id.Value); break; default: break; } } catch (Exception ex) { this.AddModelError(ex); } } if (model.id.HasValue && updateType != UpdateType.Destroy) { model = this._agencyService.GetById(model.id.Value); } return(Json(new[] { model }.ToDataSourceResult(request, ModelState))); }
public AgencyModel GetOne(string Id) { var agency = new AgencyModel(); using (GetaJobContext db = new GetaJobContext()) { var dbAgency = db.Agencies.Where(a => a.Id == Id).FirstOrDefault(); if (dbAgency == null) { agency.CompanyName = "not found"; } else { agency.CompanyName = dbAgency.JobCompany.CompanyName; agency.CompanyAddress = dbAgency.JobCompany.CompanyAddress; agency.CompanyZip = dbAgency.JobCompany.CompanyZip; agency.Email = dbAgency.JobCompany.Email; agency.Phone = dbAgency.JobCompany.OfficePhone; agency.Website = dbAgency.JobCompany.Website; } } return(agency); }
public async Task <IActionResult> EditAgency(string agencyId) { var userId = User.FindFirst(ClaimTypes.NameIdentifier).Value; if (!await _context.ManagesAgency(userId, agencyId)) { return(Forbid()); } Agency agency = await _context.GetAgency(agencyId); AgencyModel model = new AgencyModel() { AdminContactId = agency.AdminContactId, TechnicalContactId = agency.TechnicalContactId, CreatorId = agency.CreatorId, AgencyId = agency.AgencyId, Label = agency.Label }; ViewBag.People = await _context.GetPeopleForUser(userId); return(View(model)); }
public ActionResult AddAgency(AgencyModel agency) { if (string.IsNullOrEmpty(agency.AgencyName)) { AgencyModel model = new AgencyModel(); RequestModel requestModel = new RequestModel(); model.StatesList = requestModel.GetStatesList().ToList(); return(View(model)); } else { using (var context = new lifeflightapps()) { tblEmsAgencyLocal emsAgency = new tblEmsAgencyLocal() { Name = agency.AgencyName, Address = agency.AddressLn1, City = agency.City, County = agency.County, State = agency.StateCode, Zip = agency.Zip, Phones = agency.Phone, LocalUse = agency.LocalUse, Type = agency.AgencyType, BaseRate = agency.BaseRate, MileageRate = agency.MileageRate, Notes = agency.Notes }; context.tblEmsAgencyLocals.Add(emsAgency); context.SaveChanges(); int id = emsAgency.EMSID; return(RedirectToAction("GetAgencyDetails", new { agencyId = id })); } } }
public AgencyModel SignUpAgentsDetail(int AgentId) { SignUpAgents result = ent.SignUpAgents.Where(x => x.AgentId == AgentId).FirstOrDefault(); AgencyModel model = new AgencyModel(); model.AgentId = result.AgentId; model.AgencyCode = result.AgentCode; model.AgencyName = result.AgentName; model.ContactPerson = result.ContactPerson; model.NativeCountry = result.NativeCountry; model.Zone = result.ZoneId; model.District = result.DistrictId; model.Mobile = result.Mobile; model.Pincode = result.PinCode; model.Email = result.Email; model.FaxNo = result.FaxNo; model.PanCardNo = result.PanNo; model.Email = result.Email; model.FaxNo = result.FaxNo; model.PanCardNo = result.PanNo; model.PanHolderName = result.PanNoHolderName; model.Web = result.Web; model.AgentStatus = result.AgentStatus; model.TimeZoneId = (int)result.TimeZoneId; model.CreatedDate = result.CreatedDate; model.isApproved = result.isApproved; model.State = result.ZoneId; model.Phone = result.Phone; model.City = result.DistrictId; model.StateName = result.Zones.ZoneName; model.CityName = result.Districts.DistrictName; model.Password = result.Password; model.Address = result.Address; model.UserName = result.UserName; model.FullName = result.FullName; return(model); }
public static int AddAgency(AgencyModel model) { DataSet ds = new DataSet(); using (IDbConnection connection = OpenConnection()) { var p = new DynamicParameters(); p.Add("@CultureId", model.CultureId); p.Add("@AgencyCode", model.AgencyCode); p.Add("@Name", model.Name); p.Add("@AgencyStatusId", model.AgencyStatusId); p.Add("@AgencyBalance", model.AgencyBalance); p.Add("@BalancePaymentMethodId", model.BalancePaymentMethodId); p.Add("@Address", model.Address); p.Add("@Email", model.Email); p.Add("@Phone", model.Phone); p.Add("@Mobile", model.Mobile); p.Add("@CountryId", model.CountryId); p.Add("@StateId", model.StateId); p.Add("@CityId", model.CityId); p.Add("@Zip", model.Zip); p.Add("@BankAccountId", model.BankAccountId); p.Add("@Code", model.Code, DbType.Int32, ParameterDirection.Output); p.Add("@Message", model.Message, DbType.String, ParameterDirection.Output); var result = connection.Query <AccountModel>("usp_Create_Agency_General", p, commandType: CommandType.StoredProcedure).First(); if (result != null) { return(result.Id); } } return(0); }
public List <AgencyModel> GetMany() { var agencys = new List <AgencyModel>(); try { using (var db = new GetaJobContext()) { var dbAgencies = db.Agencies.ToList(); foreach (Agency dbAgency in dbAgencies) { var agency = new AgencyModel(); agency.Id = dbAgency.Id; agency.CompanyName = dbAgency.JobCompany.CompanyName; agency.CompanyAddress = dbAgency.JobCompany.CompanyAddress; //CompanyZip = dbAgency.JobCompany.CompanyZip, //Email = dbAgency.JobCompany.Email, //Phone = dbAgency.JobCompany.OfficePhone, //Website = dbAgency.JobCompany.Website foreach (Agent dbAgent in dbAgency.Agents) { var agent = new AgentModel(); agent.FName = dbAgent.Person.FName; agent.LName = dbAgent.Person.LName; agency.Agents.Add(agent); } agencys.Add(agency); } } } catch (Exception ex) { agencys.Add(new AgencyModel() { CompanyName = Helpers.ErrorDetails(ex) }); } return(agencys); }
// PUT api/values/5 public string Put(int id, AgencyModel model) { throw new NotImplementedException(); }
public ActionResult CreateAgency() { AgencyModel agency = new AgencyModel(); return(View(agency)); }
// POST api/values public string Post(AgencyModel model) { throw new NotImplementedException(); }
public void CreateUser(AgencyModel obj) { ent.CreateASPUser(obj.UserName, obj.Password, obj.Email, "AGENT", null, obj.FullName, obj.Address, obj.Mobile, obj.Phone, (int)ATLTravelPortal.Helpers.UserTypes.User, obj.CreatedbyUser, "Holidays"); }
public async Task <IActionResult> AddAgency(AgencyModel addAgencyModel) { var userId = User.FindFirst(ClaimTypes.NameIdentifier).Value; // allow two digit codes, int, and uk if (addAgencyModel != null && addAgencyModel.AgencyId != null) { int index = addAgencyModel.AgencyId.IndexOf("."); if (index != 2 && index != 3) { ModelState.AddModelError("", "The agency id must start with a 2 character ISO 3166 country code or int, For example: us.agencyname"); } else { string code = addAgencyModel.AgencyId.Substring(0, index); if (index == 2 && string.Compare(code.ToLowerInvariant(), "uk") != 0) { string projectRootPath = _hostingEnvironment.ContentRootPath; var ripeFile = Path.Combine(projectRootPath, "iso3166-countrycodes.txt"); var isoCountries = new RipeISOCountryReader().Parse(ripeFile); var isoLookup = new ISOCountryLookup <RipeCountry>(isoCountries); var isIsoCode = isoLookup.TryGetByAlpha2(code, out RipeCountry country); if (!isIsoCode) { ModelState.AddModelError("", $"{code} is not a valid country code. The agency id must start with a 2 character ISO 3166 country code or int, For example: us.agencyname"); } } else if (index == 3 && string.Compare(code.ToLowerInvariant(), "int") != 0) { ModelState.AddModelError("", "The agency id must start with a 2 character ISO 3166 country code or int, For example: us.agencyname"); } } } if (ModelState.IsValid) { Agency agency = await _context.GetAgency(addAgencyModel.AgencyId); if (agency != null) { ModelState.AddModelError("", "The agency id already exists, please try again"); } else { agency = new Agency() { AgencyId = addAgencyModel.AgencyId, ApprovalState = ApprovalState.Requested, Label = addAgencyModel.Label, CreatorId = userId, AdminContactId = userId, TechnicalContactId = userId }; agency.AdminContactId = await SelectOrInviteUser(addAgencyModel.AdminContactId, addAgencyModel.AdminContactEmail, addAgencyModel.AgencyId); agency.TechnicalContactId = await SelectOrInviteUser(addAgencyModel.TechnicalContactId, addAgencyModel.TechnicalContactEmail, addAgencyModel.AgencyId); _context.Agencies.Add(agency); await _context.SaveChangesAsync(); // Send email. var user = await _context.Users.FindAsync(userId); if (user != null) { try { await SendConfirmationEmail(user, addAgencyModel.AgencyId); } catch (Exception e) { } } var approvers = await _userManager.GetUsersInRoleAsync("admin"); foreach (var approver in approvers) { try { await SendApproverEmail(approver, user, addAgencyModel.AgencyId); } catch (Exception e) { } } return(RedirectToAction("Index", "Manage")); } } ViewBag.People = await _context.GetPeopleForUser(userId); return(View()); }