public async Task AddLocationAsync(CreateLocationViewModel newLocation, EntityHeader addedByUser) { ValidationCheck(newLocation, Core.Validation.Actions.Create); var location = new OrganizationLocation(); location.SetId(); var currentUser = await _appUserRepo.FindByIdAsync(addedByUser.Id); var organization = await _organizationRepo.GetOrganizationAsync(newLocation.OrganizationId); location.Organization = organization.ToEntityHeader(); if (EntityHeader.IsNullOrEmpty(location.AdminContact)) { location.AdminContact = addedByUser; } if (EntityHeader.IsNullOrEmpty(location.TechnicalContact)) { location.TechnicalContact = addedByUser; } SetCreatedBy(location, addedByUser); await _locationRepo.AddLocationAsync(location); }
public override void MapToOrganizationLocation(OrganizationLocation location) { base.MapToOrganizationLocation(location); location.Namespace = LocationNamespace; location.AdminContact = EntityHeader.Create(AdminContactId, AdminContact); location.TechnicalContact = EntityHeader.Create(AdminContactId, TechnicalContact); }
public async Task SaveOrganizationLocationAsync() { var authToken = Settings.TokenForUser; if (string.IsNullOrEmpty(authToken)) { return; } try { UriBuilder builder = new UriBuilder(AppSettings.GraphApiEndpoint); builder.Path = $"beta/organization/98f4e585-4aaf-43cd-b5e7-d348e33dc12c/extensions"; string uri = builder.ToString(); var organizationLocation = new OrganizationLocation { StreetName = "9825 Willows Road NE", Country = "USA", PostalCode = "98052", State = "WA", City = "Redmond" }; await _requestProvider.PostAsync <OrganizationLocation, bool>(uri, organizationLocation, authToken); } catch (Exception e) { System.Diagnostics.Debug.WriteLine($"Error init OrganizationLocation: {e}"); } }
public int InsertUpdateOrganizationLocation(OrganizationLocation location) { int id = 0; id = OrganizationDal.InsertUpdateOrganizationLocation(location); return(id); }
public bool saveLocationInfo(OrganizationLocation location) { try { InfoDL.saveLocationInfo(location); return(true); } catch (Exception e) { throw e; } }
public virtual void MapToOrganizationLocation(OrganizationLocation location) { location.Name = LocationName; location.Addr1 = Addr1; location.Addr2 = Addr2; location.City = City; location.StateProvince = StateProvince; location.PostalCode = PostalCode; location.Country = Country; location.Notes = Notes; location.Description = Description; }
public ActionResult LocationForm(int id = 0) { OrganizationLocation Location = new OrganizationLocation(); if (id > 0) { Location = _organizationBll.GetLocationsById(Helper.GetLoggedInUserOrganization(), id); } ViewBag.LocationTypes = new SelectList(_organizationBll.LocationTypes, "Id", "Type", Location.LocationType); return(View(Location)); }
public static UpdateLocationViewModel CreateForOrganizationLocation(OrganizationLocation loc) { return(new Organization.UpdateLocationViewModel() { LocationId = loc.Id, LastUpdatedDate = loc.LastUpdatedDate, Addr1 = loc.Addr1, Addr2 = loc.Addr2, City = loc.City, StateProvince = loc.StateProvince, Country = loc.Country, AdminContact = loc.AdminContact.Text, AdminContactId = loc.AdminContact.Id, TechnicalContact = loc.TechnicalContact.Text, TechnicalContactId = loc.TechnicalContact.Id }); }
public OrganizationLocation GetLocationsById(int orgId, int locationId) { OrganizationLocation location = new OrganizationLocation(); try { string procedure = "pr_GetOrganizationLocationById"; List <DbParameter> param = new List <DbParameter>(); param.Add(new DbParameter() { Name = "p_OrganizationId", Direction = ParameterDirection.Input, Type = DbType.Int32, Value = orgId }); param.Add(new DbParameter() { Name = "p_LocationId", Direction = ParameterDirection.Input, Type = DbType.Int32, Value = locationId }); DataSet dataSet = new DataSet(); dataSet = db.LoadDataSetAgainstQuery(procedure, CommandType.StoredProcedure, ref param); if (dataSet != null && dataSet.Tables.Count > 0) { location = dataSet.Tables[0].AsEnumerable().Select(a => new OrganizationLocation() { Id = Convert.ToInt32(a["Id"]), LocationName = a["vLocationName"].ToString(), LocationType = Convert.ToInt32(a["iLocationType"]), OrganizationId = Convert.ToInt32(a["iOrganizationId"] == DBNull.Value ? 0 : a["iOrganizationId"]), CreatedDate = Convert.ToDateTime(a["dInsertDate"]), CreatedUserId = Convert.ToInt32(a["iInsertUserId"]) }).FirstOrDefault(); } } catch (Exception ex) { throw ex; } return(location); }
public int InsertUpdateOrganizationLocation(OrganizationLocation location) { int id = 0; try { string procedure = "pr_InsertUpdateOrganizationLocation"; List <DbParameter> param = new List <DbParameter>(); param.Add(new DbParameter() { Name = "p_LocationId", Direction = ParameterDirection.Input, Type = DbType.Int32, Value = location.Id }); param.Add(new DbParameter() { Name = "p_vLocationName", Direction = ParameterDirection.Input, Type = DbType.String, Value = location.LocationName }); param.Add(new DbParameter() { Name = "p_iLocationType", Direction = ParameterDirection.Input, Type = DbType.Int32, Value = location.LocationType }); param.Add(new DbParameter() { Name = "p_iOrganizationId", Direction = ParameterDirection.Input, Type = DbType.Int32, Value = location.OrganizationId }); param.Add(new DbParameter() { Name = "p_iInsertUserId", Direction = ParameterDirection.Input, Type = DbType.Int32, Value = location.CreatedUserId }); id = db.ExecuteNonQuery(procedure, CommandType.StoredProcedure, ref param); } catch (Exception ex) { throw ex; } return(id); }
public ActionResult LocationForm(OrganizationLocation location) { //if (!ModelState.IsValid) //{ // return new AjaxableViewResult(location); //} location.CreatedUserId = Helper.GetLoggedInUserId(); location.OrganizationId = Helper.GetLoggedInUserOrganization(); AjaxResponse res = new AjaxResponse(); int saved = _organizationBll.InsertUpdateOrganizationLocation(location); res = new AjaxResponse() { Message = saved > 0 ? "Location Save successfully" : "Unable to save Location", Type = saved > 0 ? "success" : "error", Heading = "Location", RedirectUrl = Url.Action("LocationList", "Organization") }; return(Json(res)); }
public bool saveLocationInfo(OrganizationLocation location) { try { scon.Open(); SqlCommand command = new SqlCommand("SaveLocationInfo", scon); command.CommandType = CommandType.StoredProcedure; command.Parameters.Add("@OrganizationId", SqlDbType.BigInt).Value = location.OrganizationId; command.Parameters.Add("@Name", SqlDbType.NVarChar).Value = location.Name; command.Parameters.Add("@City", SqlDbType.NVarChar).Value = location.City; command.Parameters.Add("@Country", SqlDbType.NVarChar).Value = location.Country; command.Parameters.Add("@Address", SqlDbType.NVarChar).Value = location.Address; command.Parameters.Add("@ZipCode", SqlDbType.NVarChar).Value = location.ZipCode; command.Parameters.Add("@Phone", SqlDbType.NVarChar).Value = location.Phone; command.Parameters.Add("@Fax", SqlDbType.NVarChar).Value = location.Fax; command.Parameters.Add("@Comments", SqlDbType.NVarChar).Value = location.Comments; command.ExecuteNonQuery(); return(true); } catch (Exception e) { throw e; } }
public async Task CreateNewOrganizationAsync(CreateOrganizationViewModel organizationViewModel, EntityHeader user) { ValidationCheck(organizationViewModel, Core.Validation.Actions.Create); //HACK: Very, small chance, but it does exist...two entries could be added at exact same time and check would fail...need to make progress, can live with rish for now. if (await _organizationRepo.QueryNamespaceInUseAsync(organizationViewModel.Namespace)) { throw new ValidationException(Resources.UserManagementResources.Organization_CantCreate, false, UserManagementResources.Organization_NamespaceInUse.Replace(Tokens.NAMESPACE, organizationViewModel.Namespace)); } var organization = new Organization(); organization.SetId(); organization.SetCreationUpdatedFields(user); organizationViewModel.MapToOrganization(organization); organization.Status = UserManagementResources.Organization_Status_Active; organization.TechnicalContact = user; organization.AdminContact = user; organization.BillingContact = user; var location = new OrganizationLocation(); location.SetId(); organizationViewModel.MapToOrganizationLocation(location); location.SetCreationUpdatedFields(user); location.AdminContact = user; location.TechnicalContact = user; location.Organization = organization.ToEntityHeader(); organization.PrimaryLocation = location.ToEntityHeader(); if (organization.Locations == null) { organization.Locations = new List <EntityHeader>(); } organization.Locations.Add(location.ToEntityHeader()); var currentUser = await _appUserRepo.FindByIdAsync(user.Id); var locationUser = new LocationAccount(organization.Id, location.Id, user.Id) { Email = currentUser.Email, OrganizationName = organization.Name, AccountName = currentUser.Name, ProfileImageUrl = currentUser.ProfileImageUrl.ImageUrl, LocationName = location.Name }; locationUser.SetCreationUpdatedFields(user); await _organizationRepo.AddOrganizationAsync(organization); await AddAccountToOrgAsync(currentUser.ToEntityHeader(), organization.ToEntityHeader(), currentUser.ToEntityHeader()); await _locationRepo.AddLocationAsync(location); await _locationAccountRepo.AddAccountToLocationAsync(locationUser); if (EntityHeader.IsNullOrEmpty(currentUser.CurrentOrganization)) { currentUser.CurrentOrganization = organization.ToEntityHeader(); } if (currentUser.Organizations == null) { currentUser.Organizations = new List <EntityHeader>(); } currentUser.Organizations.Add(organization.ToEntityHeader()); await _appUserRepo.UpdateAsync(currentUser); }
public override void MapToOrganizationLocation(OrganizationLocation location) { base.MapToOrganizationLocation(location); location.Namespace = LocationNamespace; }