public object Delete(OrganizationDto organizationDto) { Db.DeleteById<Organization>(organizationDto.Id); //Db.Delete<OrganizationOrganizationCategory>(ooc => ooc.OrganizationId == organizationDto.Id); return new OrganizationResponse { Organization = new OrganizationDto() }; }
/// <summary> /// GET /organizations/{Id} /// </summary> public object Get(OrganizationDto request) { var userSession = base.SessionAs<CustomUserSession>(); var query = string.Format("select o.*, sp.Name as StateProvinceName, sp.Abbreviation as StateProvinceAbbreviation, oc.Id as OrganizationCategoryId, oc.Name as OrganizationCategoryName " + "from Organization o " + "left join StateProvince sp " + "on o.StateProvinceId = sp.Id " + "left join OrganizationCategory oc " + "on o.OrganizationCategoryId = oc.Id " + "where o.Id = {0}", request.Id); var orgDto = Db.Select<OrganizationDto>(query).FirstOrDefault(); if (orgDto != null) { //// Categories //var orgCategoryQuery = string.Format( // "select oc.* " + // "from OrganizationCategory oc " + // "inner join OrganizationOrganizationCategory ooc " + // "on oc.Id = ooc.OrganizationCategoryId " + // "where ooc.OrganizationId = {0}", orgDto.Id); //var orgCategories = Db.Select<OrganizationCategory>(orgCategoryQuery); //if (orgCategories != null) //{ // orgDto.Categories = orgCategories; //} // Allies var alliesCountQuery = string.Format("select count(*) from OrganizationAlly where OrganizationId = {0}", orgDto.Id); orgDto.OrganizationAlliesCount = Db.Scalar<int>(alliesCountQuery); // News var newsCountQuery = string.Format("select count(*) from OrganizationNews where OrganizationId = {0}", orgDto.Id); orgDto.OrganizationNewsCount = Db.Scalar<int>(newsCountQuery); // Comments var commentsCountQuery = string.Format("select count(*) from OrganizationComment where OrganizationId = {0}", orgDto.Id); orgDto.OrganizationNewsCount = Db.Scalar<int>(commentsCountQuery); //// Events //var eventsCountQuery = string.Format("select count(*) from Event where OrganizationId = {0} and StartDateTime >= '{1}'", orgDto.Id, DateTime.Now.ToString()); //orgDto.OrganizationEventsCount = Db.Scalar<int>(eventsCountQuery); if (request.CallerUserId.HasValue) { var userFollowingOrgQuery = string.Format("select count(*) from OrganizationAlly where OrganizationId = {0} and UserId = {1}", orgDto.Id, request.CallerUserId); var userFollowingCount = Db.Scalar<int>(userFollowingOrgQuery); orgDto.CallerIsFollowingOrg = userFollowingCount > 0; } } return new OrganizationResponse { Organization = orgDto }; }
public static OrganizationEditModel MapOrganizationEditModel(OrganizationDto dto) { var model = new OrganizationEditModel(); model.OrganizationUid = dto.Uid; model.Name = dto.Name; model.Description = dto.Description; model.SetInputModelValues(); return(model); }
public async void UpdateAsync_IncorrectId_ThrowsHttpStatusCodeException(int id) { // Arrange var organizationService = new OrganizationService(new EFUnitOfWork(dbOptions), mapper); var organizationDto = new OrganizationDto { Name = "Organization", Code = "S266", Type = OrganizationType.IncorporatedCompany.GetStringName() }; // Act and Assert await Assert.ThrowsAsync <HttpStatusCodeException>(() => organizationService.UpdateAsync(id, organizationDto, userEmail)); }
public async Task <IActionResult> Post([FromBody] OrganizationDto body) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var result = await _unitOfWork.Repository <Organization>().AddAsync(Mapper.Map <Organization>(body)); await _unitOfWork.Commit(); return(Ok(result.Id)); }
public static Organization ToEntity(this OrganizationDto organization) { return(new() { Slug = organization.Slug, Name = string.IsNullOrEmpty(organization.Name) ? organization.Slug : organization.Name, Description = organization.Description, CreationDate = organization.CreationDate, OwnerId = organization.Owner, IsPublic = organization.IsPublic }); }
public OrganizationCardViewModel(IMessageService <bool> messageService, IDataServiceProxy dataServiceProxy, CityDto city) : this(messageService, dataServiceProxy) { Organization = new OrganizationDto(); Organization.City_Id = city.Id; Region = city.Region; City = city; ViewTitle = "Новая запись"; ButtonName = "Сохранить"; }
public IActionResult AddOrganization(OrganizationDto model) { var organization = model.MapTo <Organization>(mapper); if (ModelState.IsValid) { unitOfWork.GetRepository <Organization>().InsertAsync(organization); unitOfWork.GetRepository <Organization>().SaveAsync(); return(new ObjectResult("Model added successfully!")); } return(new ObjectResult("Model added unsuccessfully!")); }
public ActionResult CreateTrialBalance_Group() { OrganizationService objIOrganizationService = new OrganizationService(); OrganizationDto organizationDto = objIOrganizationService.GetAll(); ViewBag.OrganizationDetails = organizationDto; TrialBalanceTotalsDto objTotals = new TrialBalanceTotalsDto(); List <TrialBalanceDto> lstTrialBalance = GetAllTrialBalanceReport_Group(objTotals); ViewBag.TrialBalanceTotals = objTotals; return(View("CreateTrialBalance", lstTrialBalance)); }
public async Task <IActionResult> Create(OrganizationDto input) { if (!ModelState.IsValid) { NotifyModelStateErrors(); Result(input); } await _organizationAppService.Create(input); return(Result(input)); }
public OrganizationDto GetAll() { var objuspOrganizationGetAllResult = _dbContext.uspOrganizationGetAll(null).ToList().FirstOrDefault(); OrganizationDto objOrganizationDto = new OrganizationDto(); if (objuspOrganizationGetAllResult != null) { objOrganizationDto = AutoMapperEntityConfiguration.Cast <OrganizationDto>(objuspOrganizationGetAllResult); } return(objOrganizationDto); }
public int CreateOrganization(OrganizationDto dto) { Organization org = new Organization() { CreationTime = DateTime.Now, CreatorUserId = _abpSession.UserId, Name = dto.Name, Description = dto.Description, InnerCode = dto.InnerCode }; return(_reposity.InsertAndGetId(org)); }
public async Task <HttpResponseMessage> AddOrganization(AddOrganizationDto organization) { var orgDto = new OrganizationDto { Name = organization.Name, Description = organization.Description, Address = organization.Address, City = organization.City, PinCode = organization.PinCode }; var data = await _organizationService.AddUpdateOrganization(orgDto); return(Request.CreateResponse(HttpStatusCode.Created, data)); }
public async Task <OrganizationDto> CreateAsync(OrganizationDto model) { Organization org = _mapper.Map <Organization>(model); org.DateCreated = DateTime.UtcNow; org.DateModified = null; await _context.Organizations.AddAsync(org); await _context.SaveChangesAsync(); model = _mapper.Map <OrganizationDto>(org); return(model); }
public OperationResult <OrganizationDto> Save(OrganizationDto organization) { if (organization == null) { throw new ArgumentNullException(nameof(organization)); } var result = (string.IsNullOrEmpty(organization.OwnerId)) ? CreateOrganization(organization) : UpdateOrganization(organization); return(result); }
private static async Task PostOrganizationToExternalSystem(Organization organization) { var tenant = HttpRequestStorage.Tenant; if (tenant.TenantID == Tenant.ActionAgendaForPugetSound.TenantID) { var organizationPostDto = new OrganizationDto(organization); var client = new HttpClient(); await client.PostAsJsonAsync( $"{FirmaWebConfiguration.PsInfoPostOrganizationUrl}/{FirmaWebConfiguration.PsInfoApiKey}", organizationPostDto); } }
public async Task <IActionResult> UpdateAsync([FromBody] OrganizationDto input) { // Map. var organization = _mapper.Map <Organization>(input); organization.Id = _appContext.TenantId; // Act. await _organizationRepository.UpdateAsync(organization); // Return. return(NoContent()); }
public static OrganizationDto ConvertToDto(this Organization organization) { OrganizationDto parent = null; if (organization.Parent != null) { parent = ConvertToDto(organization.Parent); } return(new OrganizationDto() { Id = organization.Id, Name = organization.Name, Parent = parent }); }
public GenericServiceResponse <bool> DeleteOrganization(OrganizationDto organization) { return(TryExecute <GenericServiceResponse <bool> >((response) => { response.Result = Repository.Delete(organization.AsEntity()); if (!response.Result) { var errorMessage = "'DeleteOrganization' was unable to delete the given organization record."; response.Notifications.AddError(errorMessage); Logger.Error(errorMessage); } })); }
public async Task <IActionResult> Post(OrganizationDto org) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var orgToInsert = _mapper.Map <Organization>(org); await _organizationRepository.AddAsync(orgToInsert); await _unitOfWork.SaveChangesAsync(); return(Ok(orgToInsert)); }
/// <summary> /// Выполнить команду Добавить или Обновить данные по организации иностранца /// </summary> /// <param name="invitationId">Идентификатор приглашения</param> /// <param name="organizationDto">Данные по организации</param> /// <returns>Идентификатор организации</returns> public async Task <Guid> AddOrUpdateOrganizationAsync(Guid invitationId, OrganizationDto organizationDto) { Contract.Argument.IsNotEmptyGuid(invitationId, nameof(invitationId)); var invitation = await _invitationRepository.GetAsync(invitationId); var invitedAlienId = invitation.AlienId; var alienOrganizationId = await _alienWriteCommand.AddOrUpdateOrganizationAsync(invitedAlienId, organizationDto); await _domainContext.SaveChangesAsync(); return(alienOrganizationId); }
public Organization(OrganizationDto organizationDto) { Id = organizationDto.Id; Name = organizationDto.Name; Street = organizationDto.Street; StreetExtended = organizationDto.StreetExtended; PostalCode = organizationDto.PostalCode; City = organizationDto.City; Country = organizationDto.Country; VatNumber = organizationDto.VatNumber; Website = organizationDto.Website; ChangeDate = organizationDto.ChangeDate; ChangedBy = organizationDto.ChangedBy; }
public async Task PutOrganization([FromForm] OrganizationDto organizationDto) { Organization organization = await dbContext.Organizations .Include(o => o.File) .FirstOrDefaultAsync(o => o.Id == organizationDto.Id); if (organizationDto.File != null && organization.File != null) { dbContext.Files.Remove(organization.File); } organizationDto.UpdateEntity(organization); await dbContext.SaveChangesAsync(); }
/// <summary> /// Обновить организацию /// </summary> /// <param name="currentOrganizationId">Идентификатор обновляемой организации</param> /// <param name="organizationDto">Данные для полного обновления организации</param> public async Task UpdateAsync( Guid currentOrganizationId, OrganizationDto organizationDto) { Contract.Argument.IsNotEmptyGuid(currentOrganizationId, nameof(currentOrganizationId)); Contract.Argument.IsNotNull(organizationDto, nameof(organizationDto)); var currentOrganization = await GetAsync(currentOrganizationId).ConfigureAwait(false); currentOrganization.Update( name: organizationDto.Name, shortName: organizationDto.ShortName, scientificActivity: organizationDto.ScientificActivity, legalAddress: organizationDto.LegalAddress); }
/// <summary> /// Добавить организацию /// </summary> /// <param name="addedOrganization">DTO добавляемой организации</param> public Organization Add(OrganizationDto addedOrganization) { Contract.Argument.IsNotNull(addedOrganization, nameof(addedOrganization)); var stateRegistration = _stateRegistrationService.Add(addedOrganization.StateRegistration); var organization = _organizationRepository.Create( stateRegistrationId: stateRegistration.Id, name: addedOrganization.Name, shortName: addedOrganization.ShortName, legalAddress: addedOrganization.LegalAddress, scientificActivity: addedOrganization.ScientificActivity); return(organization); }
public IHttpActionResult UpdateOrganization(string apiKey, [FromBody] OrganizationDto organizationDto) { Check.Require(apiKey == FirmaWebApiConfiguration.PsInfoApiKey, "Unrecognized api key!"); var organization = _databaseEntities.Organizations.SingleOrDefault(x => x.OrganizationID == organizationDto.OrganizationID); if (organization == null) { var message = $"Organization with ID = {organizationDto.OrganizationID} not found"; return(NotFound()); } organization.OrganizationName = organizationDto.OrganizationName; organization.KeystoneOrganizationGuid = organizationDto.OrganizationGuid; organization.OrganizationShortName = organizationDto.OrganizationShortName; organization.OrganizationTypeID = organizationDto.OrganizationTypeID; organization.IsActive = organizationDto.IsActive; organization.OrganizationUrl = organizationDto.OrganizationUrl; organization.Description = organizationDto.Description; if (organizationDto.LogoFileResource != null) { var fileResourceDto = organizationDto.LogoFileResource; var fileResourceMimeType = MapFileResourceMimeTypeNameToFileResourceMimeType(fileResourceDto.FileResourceMimeTypeName); if (fileResourceMimeType == null) { var error = $"Invalid File Resource Mime Type '{fileResourceDto.FileResourceMimeTypeName}' for '{fileResourceDto.FileResourceGUID}'"; return(BadRequest(error)); } var peopleDictionary = _databaseEntities.People.ToDictionary(x => x.Email); var fileResourceMimeTypeID = fileResourceMimeType.FileResourceMimeTypeID; var personID = peopleDictionary.ContainsKey(fileResourceDto.Email) ? peopleDictionary[fileResourceDto.Email].PersonID : 5278; var fileResourceInfo = new FileResourceInfo(fileResourceMimeTypeID, fileResourceDto.OriginalBaseFilename, fileResourceDto.OriginalFileExtension, fileResourceDto.FileResourceGUID, personID, fileResourceDto.CreateDate); fileResourceInfo.FileResourceDatas.Add(new FileResourceData(fileResourceInfo.FileResourceInfoID, fileResourceDto.FileResourceData)); var oldLogoFileResourceInfo = organization.LogoFileResourceInfo; organization.LogoFileResourceInfo = fileResourceInfo; oldLogoFileResourceInfo?.FileResourceData.Delete(_databaseEntities); oldLogoFileResourceInfo?.Delete(_databaseEntities); } _databaseEntities.SaveChangesWithNoAuditing(Tenant.ActionAgendaForPugetSound.TenantID); var fundingSourceReloaded = new OrganizationDto(organization); return(Ok(fundingSourceReloaded)); }
public async Task <IActionResult> UpdateOrganization(Guid id, OrganizationDto model) { var organization = model.MapTo <Organization>(mapper); var newOrganization = await unitOfWork.GetRepository <Organization>().GetByIdAsync(id); newOrganization.Name = organization.Name; newOrganization.Post = organization.Post; if (ModelState.IsValid && id == model.Id) { unitOfWork.GetRepository <Organization>().Update(newOrganization); unitOfWork.GetRepository <Organization>().SaveAsync(); return(new ObjectResult("Model updated successfully!")); } return(new ObjectResult("Model updated unsuccessfully!")); }
public static Organization ConvertFromDto(this OrganizationDto organizationDto) { if (organizationDto == null) { return(null); } Organization parent = null; if (organizationDto.Parent != null) { parent = ConvertFromDto(organizationDto.Parent); } return(new Organization(organizationDto.Id, organizationDto.Name, parent)); }
public IHttpActionResult CreateOrganization(OrganizationDto organizationDto) { if (!ModelState.IsValid) { return(BadRequest()); } var organization = Mapper.Map <OrganizationDto, Organization>(organizationDto); _context.Organizations.Add(organization); _context.SaveChanges(); organizationDto.Id = organization.Id; return(Created(new Uri(Request.RequestUri, "/" + organization.Id), organizationDto)); }
public async Task <DResult <OrganizationDto> > CorrelateOrganization([FromBody] PartnerDto partnerDto) { try { OrganizationDto organization = businessOrganization.CorrelateOrganization(partnerDto); if (organization == null) { return(DResult.Error <OrganizationDto>("未找到该机构", 501)); } return(DResult.Succ(organization)); } catch (Exception ex) { Logger.Error(ex.ToString()); return(DResult.Error <OrganizationDto>(ex.Message, 500)); } }
public ActionResult Edit(int id) { var dto = IdentityContract.Organizations.Where(c => c.Id == id).Select(m => new OrganizationDto { Id = m.Id, Name = m.Name, Remark = m.Remark, SortCode = m.SortCode, ParentId = m.Parent.Id, ParentName=m.Parent.Name }).SingleOrDefault(); if (dto == null) dto = new OrganizationDto(); return View(dto); }
private void SelectOrganization(OrganizationDto organization) { try { if (organization != null) { _controller.GetConfigs <OrganizationCardView, OrganizationCardViewModel>() .AdditionalViewModelParams(organization) .RunDialog(); } } catch (Exception ex) { MessageService.ShowError(ex.Message); } }
public IHttpActionResult PostOrganization(string apiKey, [FromBody] OrganizationDto organizationDto) { Check.Require(apiKey == FirmaWebApiConfiguration.PsInfoApiKey, "Unrecognized api key!"); var tenantID = Tenant.ActionAgendaForPugetSound.TenantID; // If Organization already exists because it was created by Keystone - do an Update instead of a create if (_databaseEntities.Organizations.Any(x => x.OrganizationName == organizationDto.OrganizationName)) { var existingOrganization = _databaseEntities.Organizations.Single(x => x.OrganizationName == organizationDto.OrganizationName); // Give the Dto the correct Organization ID and OrganizationTypeID for ProjectFirma organizationDto.OrganizationID = existingOrganization.OrganizationID; organizationDto.OrganizationTypeID = _databaseEntities.OrganizationTypes.SingleOrDefault(x => x.OrganizationTypeName == organizationDto.OrganizationTypeName)?.OrganizationTypeID ?? _databaseEntities.OrganizationTypes.Single(x => x.IsDefaultOrganizationType).OrganizationTypeID; return(UpdateOrganization(apiKey, organizationDto)); } var organization = new Organization(organizationDto.OrganizationName, organizationDto.IsActive, organizationDto.OrganizationTypeID, true, false); organization.KeystoneOrganizationGuid = organizationDto.OrganizationGuid; organization.OrganizationShortName = organizationDto.OrganizationShortName; organization.OrganizationUrl = organizationDto.OrganizationUrl; organization.Description = organizationDto.Description; if (organizationDto.LogoFileResource != null) { var fileResourceDto = organizationDto.LogoFileResource; var fileResourceMimeType = MapFileResourceMimeTypeNameToFileResourceMimeType(fileResourceDto.FileResourceMimeTypeName); if (fileResourceMimeType == null) { var error = $"Invalid File Resource Mime Type '{fileResourceDto.FileResourceMimeTypeName}' for '{fileResourceDto.FileResourceGUID}'"; return(BadRequest(error)); } var peopleDictionary = _databaseEntities.People.ToDictionary(x => x.Email); var fileResourceMimeTypeID = fileResourceMimeType.FileResourceMimeTypeID; var personID = peopleDictionary.ContainsKey(fileResourceDto.Email) ? peopleDictionary[fileResourceDto.Email].PersonID : 5278; var fileResourceInfo = new FileResourceInfo(fileResourceMimeTypeID, fileResourceDto.OriginalBaseFilename, fileResourceDto.OriginalFileExtension, fileResourceDto.FileResourceGUID, personID, fileResourceDto.CreateDate); fileResourceInfo.FileResourceDatas.Add(new FileResourceData(fileResourceInfo.FileResourceInfoID, fileResourceDto.FileResourceData)); organization.LogoFileResourceInfo = fileResourceInfo; } _databaseEntities.AllOrganizations.Add(organization); _databaseEntities.SaveChangesWithNoAuditing(tenantID); var organizationReloaded = new OrganizationDto(organization); return(Ok(organizationReloaded)); }
public object Put(OrganizationDto organizationDto) { var organization = organizationDto.ToEntity(); Db.Update(organization); //Db.Delete<OrganizationOrganizationCategory>(ooc => ooc.OrganizationId == organizationDto.Id); //if (organizationDto.Categories != null && organizationDto.Categories.Any()) //{ // Db.InsertAll(organizationDto.Categories.Select(c => new OrganizationOrganizationCategory // { // OrganizationCategoryId = c.Id, // OrganizationId = organizationDto.Id // })); //} return new OrganizationResponse { Organization = new OrganizationDto() }; }
public object Post(OrganizationDto request) { var organization = request.ToEntity(); Db.Insert(organization); var newOrgId = (int)Db.GetLastInsertId(); //Db.Delete<OrganizationOrganizationCategory>(ooc => ooc.OrganizationId == newOrgId); //if (organizationDto.Categories != null && organizationDto.Categories.Any()) //{ // Db.InsertAll(organizationDto.Categories.Select(c => new OrganizationOrganizationCategory // { // OrganizationCategoryId = c.Id, // OrganizationId = newOrgId // })); //} return new OrganizationResponse { Organization = new OrganizationDto() }; }
public ActionResult EditOrgan(OrganizationDto dto) { dto.CheckNotNull("dto"); OperationResult result = IdentityContract.EditOrganizations(dto); return Json(result.ToAjaxResult()); }