예제 #1
0
        public async Task <CompanyDto> CreateCompanyAsync([FromBody] CompanyDto companyDto)
        {
            var userId  = this.GetCurrentUserId();
            var company = await _companyDataService.CreateCompanyAsync(userId, companyDto);

            var result = _mapper.Map <CompanyDto>(company);

            return(result);
        }
 public ActionResult Put(long id, [FromBody] CompanyDto model)
 {
     _companyService.Update(id, model);
     if (!ModelState.IsValid)
     {
         return(BadRequest(ModelState));
     }
     return(NoContent());
 }
예제 #3
0
        // POST: api/Company
        public IHttpActionResult Post([FromBody] CompanyDto value)
        {
            Company company = Mapper.Map <Company>(value);

            repo.InsertCompany(company);
            repo.Save();

            return(Ok(company.Id));
        }
        public ActionResult Delete(Int32 id, CompanyDto company)
        {
            if (id != company.Id)
                throw new InvalidOperationException("IDs do not match");

            _api.DeleteCompany(id);

            return RedirectToAction("Index");
        }
        public ActionResult Post([FromBody] CompanyDto model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var key = _companyService.Create(model);

            return(Created($"api/company/" + key, key));
        }
        public CompanyDto Build(Company company)
        {
            var companyDto = new CompanyDto()
            {
                Id    = company.Id,
                Title = company.Title
            };

            return(companyDto);
        }
예제 #7
0
        public void Update(long id, CompanyDto companyDto)
        {
            Company company = _unitOfWork.CompanyRepository.GetFirstOrDefaultInclude(filter: x => x.Id == id, includeProperties: x => x.Employees);

            company.Name = companyDto.Name;
            company.EstablishmentYear = companyDto.EstablishmentYear;
            company.Employees         = _mapper.Map <List <Employe> >(companyDto.Employees);
            _unitOfWork.CompanyRepository.Update(company);
            _unitOfWork.Save();
        }
예제 #8
0
        public bool Remove(CompanyDto SecurityCompany)
        {
            ResponseDto response = SecurityCompanyServiceAdapter.Execute(s => s.Delete(SecurityCompany));

            if (response.Response.HasException)
            {
                return(false);
            }
            return(true);
        }
예제 #9
0
        public async Task <Company> CreateCompanyAsync(int userId, CompanyDto companyDto)
        {
            var company = _mapper.Map <Company>(companyDto);

            company.UserId = userId;
            _dbContext.Companies.Add(company);
            await _dbContext.SaveChangesAsync();

            return(company);
        }
예제 #10
0
        public void UpdateCompanyAsync(CompanyDto company)
        {
            var entity = _mapper.Map <Company>(company);

            _context.Entry(entity).State = EntityState.Modified;
            _context.Entry(entity).Property(x => x.CreatedAt).IsModified        = false;
            _context.Entry(entity).Property(x => x.UserCommercialId).IsModified = false;

            _context.SaveChanges();
        }
예제 #11
0
        public IActionResult AddCompany([FromBody] CompanyDto company)
        {
            if (ModelState.IsValid)
            {
                _companyService.AddCompany(company);
                return(StatusCode(StatusCodes.Status201Created));
            }

            return(BadRequest());
        }
 private bool ValidateUpdate(CompanyDto company)
 {
     if (company.Name != null && company.FoundedDate != null)
     {
         _logger.LogInformation("Validate accepted");
         return(true);
     }
     _logger.LogInformation("Validate unaccepted");
     return(false);
 }
예제 #13
0
        public IActionResult UpdateCompany([FromBody] CompanyDto company)
        {
            if (ModelState.IsValid)
            {
                _companyService.UpdateCompany(company);
                return(StatusCode(StatusCodes.Status204NoContent));
            }

            return(BadRequest());
        }
예제 #14
0
        public IActionResult AddCompany([FromBody] CompanyDto companyDto)
        {
            if (companyDto == null)
            {
                return(BadRequest("Invalid model"));
            }
            var result = _companyService.AddCompany(companyDto);

            return(Ok(result));
        }
예제 #15
0
        public async Task <IActionResult> UpdateCompany(int id, CompanyToUpdateDto companyToUpdate)
        {
            CompanyDto updatedCompany = await _service.UpdateCompany(id, companyToUpdate);

            if (updatedCompany == null)
            {
                return(StatusCode(404));
            }
            return(StatusCode(200, updatedCompany));
        }
예제 #16
0
        public async Task <ActionResult <CompanyDto> > Register(CompanyDto registerCompany)
        {
            if (await _CompanyService.CompanyExists(registerCompany.name))
            {
                return(BadRequest("მსგავსი კომპანია უკვე არსებობს"));
            }
            var user = await _CompanyService.RegisterCompany(registerCompany);

            return(Ok("წარმატებით დაემატა"));
        }
예제 #17
0
        public async Task <int> AddCompany(CompanyDto companyDto)
        {
            var companyEntity = new CompanyEntity(companyDto);

            await this.companyDbContext.Companies.AddAsync(companyEntity);

            await this.companyDbContext.SaveChangesAsync();

            return(companyEntity.Id);
        }
예제 #18
0
        /// <summary>
        ///  Return new company objects.
        /// </summary>
        /// <param name="code">Code of the company.</param>
        /// <returns>Create a new company.</returns>
        public ICompanyData GetNewCompanyDo(string code)
        {
            CompanyDto dto = new CompanyDto();

            dto.Code = code;
            ICompanyData data = new Company();

            data.Value = dto;
            return(data);
        }
예제 #19
0
        public static void NewCompany(CompanyDto companyDto)
        {
            Company company = AutoMapperConfiguration.mapper.Map <Company>(companyDto);

            using (placementDepartmentDBEntities placementDepartmentDB = new placementDepartmentDBEntities())
            {
                placementDepartmentDB.Company.Add(company);
                placementDepartmentDB.SaveChanges();
            }
        }
예제 #20
0
        public async Task <IActionResult> CreateCompany(CompanyToCreateDto companyToCreate)
        {
            CompanyDto createdCompany = await _service.CreateCompany(companyToCreate);

            if (createdCompany == null)
            {
                return(StatusCode(400));
            }
            return(StatusCode(200, createdCompany));
        }
예제 #21
0
        public async Task <int> CreateAsync(CompanyDto companyDto)
        {
            var company = mapper.Map <Company>(companyDto);

            await dbContext.Company.AddAsync(company);

            await dbContext.SaveChangesAsync();

            return(company.Id);
        }
        /// <summary>
        /// Creates company
        /// </summary>
        /// <param name = "company" > product </param >
        public async Task <Guid> CreateCompanyAsync(CompanyDto company)
        {
            using (var uow = UnitOfWorkProvider.Create())
            {
                var companyId = companyService.Create(company);
                await uow.Commit();

                return(companyId);
            }
        }
예제 #23
0
        public async Task <CreatedResponseDto> CreateAsync(CompanyDto companyDto)
        {
            CompanyModel companyModel = _mapper.Map <CompanyModel>(companyDto);
            await _unitOfWork.CompaniesRepository.InsertAsync(companyModel);

            await _unitOfWork.SaveAsync();

            companyDto.Id = companyModel.Id;
            return(_mapper.Map <CreatedResponseDto>(companyDto));
        }
예제 #24
0
        public async Task <ActionResult> CreateOrUpdate(CompanyDto companyDto)
        {
            if (ModelState.IsValid)
            {
                await _companyAppService.SaveAsync(companyDto, userName);

                return(RedirectToAction("Index"));
            }
            return(PartialView("_CreateOrUpdate", companyDto));
        }
        public async Task Should_Add_CompanyCorrectly()
        {
            using (IDbConnection conn = _sqlExecutor.OpenNewDbConnection())
            {
                var        companyId = _companyDataService.GetNewId();
                var        company   = _companyDataService.GetNewCompanyDo(companyId);
                var        officeId  = _dataServices.GetOfficeDataServices().GetNewId();
                CompanyDto c         = company.Value;
                Random     random    = new Random();
                c.NOMBRE         = "Karve" + random.Next() % 1000;
                c.POBLACION      = "Barcelona";
                c.PROVINCIA      = "08";
                c.CP             = "08100";
                c.FAX            = "3489498";
                c.TELEFONO       = "349019";
                c.ULTMODI        = DateTime.Now.ToString("yyyyMMddHH:mm");
                c.NIF            = "Y17267";
                c.RESPDNI        = "Y7376161";
                c.USUARIO        = "CV";
                c.OBS1           = "Great company";
                c.USUARIOWEB_EMP = "karlos";
                c.PWDWEB_EMP     = "Password";
                c.FEC_ALTA       = DateTime.Now;
                c.FEC_BAJA       = DateTime.Now.AddDays(30);
                c.DIRECCION      = "Calle Rocafort 239";
                if (c != null)
                {
                    c.Offices = new List <OfficeDtos>()
                    {
                        new OfficeDtos()
                        {
                            Codigo    = officeId,
                            Nombre    = "LaViaZia",
                            DIRECCION = "CalleToma",
                            PROVINCIA = "08",
                            CP        = "08",
                            NACIO     = "34",
                            POBLACION = "Barcelona"
                        }
                    };
                }
                // prepare
                company.Value = c;
                bool value = await _companyDataService.SaveAsync(company);

                Assert.IsTrue(value);
                var companyValue = await _companyDataService.GetAsyncCompanyDo(companyId);

                Assert.NotNull(companyValue);
                Assert.AreEqual(companyValue.Value.NOMBRE, c.NOMBRE);
                Assert.AreEqual(companyValue.Value.TELEFONO, c.TELEFONO);
                Assert.AreEqual(companyValue.Value.NIF, c.NIF);
                Assert.AreEqual(companyValue.Value.CP, c.CP);
            }
        }
예제 #26
0
        public CompanyDto Insert(CompanyDto SecurityCompany)
        {
            CompanyDto result = (CompanyDto)SecurityCompanyServiceAdapter.Execute(s => s.Insert(SecurityCompany));

            if (result.Response.HasException)
            {
                return(null);
            }
            SecurityCompany.CompanyId = result.CompanyId;
            return(SecurityCompany);
        }
예제 #27
0
        public async Task <IActionResult> CreateCompany([FromBody] CompanyDto companyDto)
        {
            await _companyRepository.Create(companyDto);

            if (companyDto == null)
            {
                return(StatusCode(StatusCodes.Status400BadRequest));
            }

            return(StatusCode(StatusCodes.Status201Created));
        }
예제 #28
0
        public async Task <IActionResult> EditCompany(CompanyDto company)
        {
            if (ModelState.IsValid && company.UserId == int.Parse(User.Identity.Name))
            {
                await companyFacade.EditInfoAsync(company);

                return(RedirectToAction("Index", "Home"));
            }

            throw new ArgumentException();
        }
예제 #29
0
        public async Task <IActionResult> AddCompany(CompanyDto company)
        {
            if (ModelState.IsValid)
            {
                await companyFacade.AddAsync(company);

                return(RedirectToAction("Login", "User"));
            }

            throw new ArgumentException();
        }
예제 #30
0
 public ActionResult UpdateCompanyProfile(CompanyDto request)
 {
     if (_companyRepository.UpdateCompanyProfile(request))
     {
         return(new JsonErrorResult(new { Message = "Company Profile Updated" }, HttpStatusCode.OK));
     }
     else
     {
         return(new JsonErrorResult(new { Message = "Company Profile Update Failed" }, HttpStatusCode.NotFound));
     }
 }
예제 #31
0
        public static void CompanyEditing(CompanyDto companyDto)
        {
            Company company = AutoMapperConfiguration.mapper.Map <Company>(companyDto);

            using (placementDepartmentDBEntities placementDepartmentDB = new placementDepartmentDBEntities())
            {
                placementDepartmentDB.Company.Attach(company);
                placementDepartmentDB.Entry(company).State = EntityState.Modified;
                placementDepartmentDB.SaveChanges();
            }
        }
예제 #32
0
파일: CompanySvc.cs 프로젝트: hqpsoft/SEMS
 public void CreatCompany(CompanyDto dto)
 {
     var entity = Mapper.Map<CompanyDto, Company>(dto);
     entity.CreateBy = 0;
     entity.CreateDate = DateTime.Now;
     using (var dbScope = _dbScopeFactory.Create())
     {
         var db = dbScope.DbContexts.Get<SEMSDbContext>();
         var data = db.Companies.Add(entity);
         db.SaveChanges();
     }
 }
예제 #33
0
파일: CompanySvc.cs 프로젝트: hqpsoft/SEMS
 public void EditCompany(CompanyDto dto)
 {
     var entity = Mapper.Map<CompanyDto, Company>(dto);
     entity.ModifyBy = 0;
     entity.ModifyDate = DateTime.Now;
     using (var dbScope = _dbScopeFactory.Create())
     {
         var db = dbScope.DbContexts.Get<SEMSDbContext>();
         db.Update(entity, r => new { r.CompanyName, r.ModifyBy, r.ModifyDate, r.Remark, r.ParentId });
         db.SaveChanges();
     }
 }
        public CompanyDto AddCompany(CompanyDto companyDto)
        {
            var company = new Company
            {
                Name = companyDto.Name,
                Notes = companyDto.Notes
            };
            var addedCompany = _context.Companies.Add(company);
            _context.SaveChanges();

            var addedCompanyDto = Mapper.Map<Company, CompanyDto>(addedCompany);

            return addedCompanyDto;
        }
예제 #35
0
        private void ShowTree(CompanyDto company)
        {
            var tvCompanyItem = new TreeViewItem
                                    {
                                        Header = company.Name
                                    };
            this.treeCompany.Items.Add(tvCompanyItem);

            foreach (var dept in company.Departments)
            {
                var tv = new TreeViewItem
                {
                    Header = dept.Details.Name,
                    Tag = new Uri(string.Format(@"/DepartmentDetailsPage.xaml?id={0}", dept.Details.Id), UriKind.Relative)
                };
                tvCompanyItem.Items.Add(tv);
                GetSubTree(ref tv, dept);
            }
        }
        public ActionResult Create(CompanyDto companyDto)
        {
            _api.AddCompany(companyDto);

            return RedirectToAction("Index");
        }
        public void UpdateCompany(CompanyDto companyDto)
        {
            var company = _context.Companies.Find(companyDto.Id);

            company.Name = companyDto.Name;
            company.Notes = companyDto.Notes;

            _context.SaveChanges();
        }
        public ActionResult Edit(Int32 id, CompanyDto companyDto)
        {
            if (id != companyDto.Id)
                throw new InvalidOperationException("IDs do not match");

            _api.UpdateCompany(companyDto);

            return RedirectToAction("Index");
        }