public void Save(CompanyEntity entityObject)
        {
            System.Threading.ThreadPool.QueueUserWorkItem(delegate
            {
                try
                {
                    ShowLoading(StringResources.captionInformation, StringResources.msgLoading);

                    var updatedEntity = Factory.Resolve <ICompanyDS>().AddOrUpdateCompany(entityObject);

                    HideLoading();

                    //display to UI
                    Application.Current.Dispatcher.Invoke(new Action(() =>
                    {
                        SelectedCompany = updatedEntity;
                        AddOrUpdateCompany(SelectedCompany);
                    }));
                }
                catch (Exception ex)
                {
                    HideLoading();
                    ShowMessageBox(StringResources.captionError, ex.ToString(), MessageBoxButton.OK);
                }
            });
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,name,catchPhrase,bs")] CompanyEntity companyEntity)
        {
            if (id != companyEntity.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(companyEntity);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CompanyEntityExists(companyEntity.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(companyEntity));
        }
        public bool DoesAnotherCompanyWithThisNameExist(CompanyEntity ce)
        {
            var companyExists = DataContext.Companies.Any(d => d.CompanyName == ce.CompanyName &&
                                                          d.CompanyId != ce.CompanyId);

            return(companyExists);
        }
        public int Post([FromBody] CompanyEntity company)
        {
            try
            {
                //var CompanyLogo = HttpContext.Current.Request.Files["CompanyLogo"];
                //var data = HttpContext.Current.Request.Form["data"];

                //var company = JsonConvert.DeserializeObject<CompanyEntity>(data);

                //string path = HttpContext.Current.Server.MapPath("~/UploadedDocuments");
                //bool folderExists = Directory.Exists(path);
                //if (!folderExists)
                //    Directory.CreateDirectory(path);

                //var fileName = DateTime.Now.Ticks + Path.GetExtension(CompanyLogo.FileName);

                //var fileSavePath = Path.Combine(path, fileName);
                //CompanyLogo.SaveAs(fileSavePath);

                //if (File.Exists(fileSavePath))
                //{
                //    company.CompanyLogo = fileName;
                //}
                //else
                //{
                //    return -1;
                //}
                return(_companyServices.CreateCompany(company));
            }
            catch (Exception ex)
            {
                throw new ApiDataException(1000, "Company Not Found", HttpStatusCode.NotFound);
            }
        }
Exemplo n.º 5
0
        public async Task <CompanyModel> HireMember(AuthorizedDto <FireHireDto> model)
        {
            return(await Execute(async() => {
                using (UnitOfWork db = new UnitOfWork())
                {
                    AccountEntity account = await db.GetRepo <AccountEntity>().Get(model.Data.AccountId.Value);
                    CompanyEntity company = await db.GetRepo <CompanyEntity>().Get(model.Data.CompanyId.Value);

                    if (account == null)
                    {
                        throw new NotFoundException("Account");
                    }

                    if (account.company_id.HasValue)
                    {
                        throw new AlreadyHiredException();
                    }

                    account.company_id = model.Data.CompanyId;

                    IList <RoleEntity> defaultRoles = await db.GetRepo <RoleEntity>().Get(role => role.is_default);

                    account.Roles.Remove(defaultRoles.FirstOrDefault(role => role.name == DefaultRoles.AUTHORIZED.ToName()));
                    account.Roles.Add(defaultRoles.FirstOrDefault(role => role.name == DefaultRoles.HIRED.ToName()));

                    account.Bosses.Add(company.Owner);

                    await db.Save();

                    await RoleService.CreateCompanyWorkerRole(account.id);

                    return await GetCompany(account.company_id.Value);
                }
            }));
        }
Exemplo n.º 6
0
        public void GetAllProjectsOfCompany_GoodWeather()
        {
            var company = new CompanyEntity()
            {
                Name = "MySuccessfulCompany", Description = "Best company ever"
            };

            _context.Projects.Add(new ProjectEntity()
            {
                Name = "Super-duper project", Description = "The most amazing project ever"
            });

            _context.Projects.Add(new ProjectEntity()
            {
                Name = "Kind of messy project", Description = "Hmm, this one can definitely be improved"
            });

            company.Projects = new List <ProjectEntity>()
            {
                _context.Projects.Find(1), _context.Projects.Find(2)
            };
            _context.Companies.Add(company);

            var res = _controller.GetAll(1) as OkNegotiatedContentResult <List <ProjectResource> >;

            Assert.IsNotNull(res);
            Assert.AreEqual(2, res.Content.Count);
            Assert.AreEqual("Super-duper project", res.Content[0].Name);
            Assert.AreEqual("Kind of messy project", res.Content[1].Name);
        }
Exemplo n.º 7
0
        public async Task <DomainCompany> AddAsync(DomainCompany company)
        {
            company.Created = DateTime.UtcNow;
            company.Email   = company.Email.ToLowerInvariant();

            CompanyEntity entity = _mapper.Map <DomainCompany, CompanyEntity>(company);

            // Creating customer in billing system
            var customerCreateOptions = new DomainCustomerCreateOptions
            {
                Email = entity.Email
            };

            DomainCustomer customer;

            try
            {
                customer = await _billingCustomerService.AddAsync(customerCreateOptions);
            }
            catch (BillingException e)
            {
                throw new BadRequestException(string.Format("Failed to register customer {0}: {1}", entity.Email, e));
            }

            entity.BillingCustomerId = customer.Id;
            entity = await _companyRepository.AddAsync(entity);

            return(_mapper.Map <CompanyEntity, DomainCompany>(entity));
        }
Exemplo n.º 8
0
        private void Save()
        {
            if (Helpers.CheckEmpty(errorProvider1, txtNameInKhmer, txtNameInEnglish, txtEmail,
                                   txtPhone, txtLocation))
            {
                return;
            }
            else
            {
                SaveCompleted = true;
                errorProvider1.Clear();
                string        text          = StringCipher.Encrypt(txtPhone.Text);
                CompanyEntity companyEntity = new CompanyEntity();
                companyEntity.NameInEnglish = txtNameInEnglish.Text;
                companyEntity.NameInKhmer   = txtNameInKhmer.Text;
                companyEntity.Email         = txtEmail.Text;
                companyEntity.Phone         = txtPhone.Text;
                companyEntity.Location      = txtLocation.Text;
                companyEntity.Active        = chkActive.Checked;
                companyEntity.Logo          = myPicture1.GetByteArrayFromBrowse();

                if (companyID != Guid.Empty)
                {
                    companyEntity.Id = companyID;
                    companyEntity.Update(USER.UserName);
                    CompanyDao.Update(companyEntity);
                }
                else
                {
                    companyEntity.Id = Guid.NewGuid();
                    companyEntity.Create(USER.UserName);
                    CompanyDao.Insert(companyEntity);
                }
            }
        }
Exemplo n.º 9
0
        public Guid CreateClient <TUser>(TCompany client, TUser user) where TUser : IUser
        {
            try
            {
                ///converting client to cliententity

                CompanyEntity clientEntity = AutoMapper.Mapper.Map <CompanyEntity>(client);

                //set DateCreated to System current date so that even wrong date is coming from TClient, it will not insert wrong date
                clientEntity.DateCreated = DateTime.Now;
                //user.UID = Guid.NewGuid();
                // user.Status = 0;
                user.UserType      = 1; //Admin of client
                user.DateCreated   = DateTime.Now;
                clientEntity.Users = new List <UserProfileEntity>();
                clientEntity.Users.Add(AutoMapper.Mapper.Map <UserProfileEntity>(user));
                _context.Clients.Add(clientEntity);
                _context.SaveChanges();
                return(clientEntity.Users.First().UID);
            }
            catch (System.Data.Entity.Infrastructure.DbUpdateException ex)
            {
                throw new Exception("Email Address already exists");
            }
        }
Exemplo n.º 10
0
        public Company GetClientByID(int id)
        {
            CompanyEntity Clientvalues = _context.Clients.Find(id);
            var           Client       = (Company)AutoMapper.Mapper.Map <Company>(Clientvalues);

            return(Client);
        }
Exemplo n.º 11
0
        public int delete(int id)
        {
            AbstractCommonData entity   = new CompanyEntity();
            string             delQuery = "DELETE FROM " + entity.TableName + " where " + entity.IndexFieldName + "=" + provider.getSQLString(id);

            return(provider.delete(delQuery));
        }
Exemplo n.º 12
0
        /// <summary>
        /// 新增公司信息
        /// </summary>
        /// <returns></returns>
        public ActionResult Add()
        {
            string CompanyNum  = WebUtil.GetFormValue <string>("CompanyNum");
            string CompanyName = WebUtil.GetFormValue <string>("CopanyName");
            string CreateUser  = WebUtil.GetFormValue <string>("CreateUser");

            CompanyEntity entity = new CompanyEntity();

            entity.CompanyNum  = CompanyNum;
            entity.CompanyName = CompanyName;
            entity.CreateUser  = CreateUser;

            CompanyProvider provider   = new CompanyProvider();
            int             line       = provider.Add(entity);
            DataResult      dataResult = new DataResult();

            if (line > 0)
            {
                dataResult.Code    = (int)EResponseCode.Success;
                dataResult.Message = "新增成功";
            }
            else
            {
                dataResult.Code    = (int)EResponseCode.Success;
                dataResult.Message = "新增失败";
            }

            return(Content(JsonHelper.SerializeObject(dataResult)));
        }
Exemplo n.º 13
0
        /// <summary>
        /// 编辑公司信息
        /// </summary>
        /// <returns></returns>
        public ActionResult Edit()
        {
            string CompanyID   = WebUtil.GetFormValue <string>("CompanyID");
            string CompanyName = WebUtil.GetFormValue <string>("CompanyName");

            CompanyProvider provider = new CompanyProvider();
            CompanyEntity   entity   = new CompanyEntity();

            entity.CompanyID   = CompanyID;
            entity.CompanyName = CompanyName;

            int line = provider.Update(entity);

            DataResult dataResult = new DataResult();

            if (line > 0)
            {
                dataResult.Code    = (int)EResponseCode.Success;
                dataResult.Message = "编辑成功";
            }
            else
            {
                dataResult.Code    = (int)EResponseCode.Exception;
                dataResult.Message = "编辑失败";
            }
            return(Content(JsonHelper.SerializeObject(dataResult)));
        }
Exemplo n.º 14
0
        public IHttpActionResult GetCompanyByID(string id)
        {
            CompanyEntity companyEntity = new CompanyEntity();
            ResultEntity  result        = new ResultEntity();

            try
            {
                COMPANY temp = dal.FindCompanyByID(new Guid(id));
                companyEntity = temp.ToCompanyEntity();
                if (temp.COMPANY1 != null)
                {
                    companyEntity.SubCompanies = temp.COMPANY1.ToList <COMPANY>().ConvertAll <CompanyEntity>(c => c.ToCompanyEntity());
                }
                if (temp.COMPANY2 != null)
                {
                    companyEntity.ParentCompany = temp.COMPANY2.ToCompanyEntity();
                }
                if (temp.USERs != null)
                {
                    companyEntity.Users = temp.USERs.ToList <USER>().ConvertAll <UserEntity>(u => u.ToUserEntity());
                }
            }
            catch (Exception e)
            {
                result.Message = e.Message;
                NtripProxyLogger.LogExceptionIntoFile("调用接口api/Company/GetCompanyByID/{id}异常,异常信息为:" + e.Message);
            }

            result.IsSuccess = result.Message == null;
            result.Data      = companyEntity;
            return(Json <ResultEntity>(result));
        }
Exemplo n.º 15
0
        public async Task <DomainCompany> UpdateByUserAsync(string userId, CompanyUpdateOptions update)
        {
            CompanyEntity company = await _companyRepository.FindByUserAsync(userId);

            if (company == null)
            {
                throw new NotFoundException(string.Format("Could not find company by user id '{0}'.", userId));
            }

            if (company.State == (int)ResourceState.Blocked)
            {
                throw new ForbiddenException(string.Format("Company {0} is blocked", company.Id));
            }
            if (company.State == (int)ResourceState.Deleted)
            {
                throw new NotFoundException(string.Format("Company {0} is deleted", company.Id));
            }

            // Patching
            company.Name     = update.Name;
            company.NameSort = update.Name == null ? null : update.Name.ToLowerInvariant();
            company.Country  = update.Country;
            company.Ein      = update.Ein;
            company.Address  = update.Address;
            company.ZipCode  = update.ZipCode;
            company.Phone    = update.Phone;
            company.Email    = update.Email;

            company = await _companyRepository.UpdateAsync(company);

            return(_mapper.Map <CompanyEntity, DomainCompany>(company));
        }
Exemplo n.º 16
0
        private void UpdateStorageCellPlacements(
            CompanyEntity company, ICollection <StorageCellEntity> storageCells,
            ICollection <StorageCellPlacementDto> storageCellPlacements
            )
        {
            foreach (StorageCellPlacementDto storageCellPlacement in storageCellPlacements)
            {
                StorageCellEntity storageCellEntity = storageCells.FirstOrDefault(
                    pi => pi.id == storageCellPlacement.StorageCellId.Value
                    );

                ManufactoryEntity manufactoryPlacement = GetManufactoryByPoint(
                    company, storageCellPlacement.X.Value, storageCellPlacement.Y.Value
                    );

                if (manufactoryPlacement == null)
                {
                    throw new PlacementException();
                }

                storageCellEntity.manufactory_id = manufactoryPlacement.id;
                storageCellEntity.x = storageCellPlacement.X;
                storageCellEntity.y = storageCellPlacement.Y;
            }
        }
Exemplo n.º 17
0
        public frmReLogin()
        {
            InitializeComponent();
            this.FormClosing       += new FormClosingEventHandler(frmReLogin_FormClosing);
            comboBox1.DisplayMember = "COMPANY_NAME";
            comboBox1.ValueMember   = "COMPANY_CODE";

            comboBox2.DisplayMember = "PLINE_NAME";
            comboBox2.ValueMember   = "RMES_ID";

            comboBox3.DisplayMember = "STATION_NAME";
            comboBox3.ValueMember   = "RMES_ID";

            comboBox4.DisplayMember = "SHIFT_NAME";
            comboBox4.ValueMember   = "RMES_ID";

            comboBox5.DisplayMember = "TEAM_NAME";
            comboBox5.ValueMember   = "RMES_ID";

            comboBox1.DataSource = CompanyFactory.GetAll();
            string _companycode = DB.ReadConfigLocal("COMPANY_CODE");

            if (!_companycode.Equals(string.Empty))
            {
                comboBox1.SelectedValue = _companycode;
                CompanyEntity company = CompanyFactory.GetByKey(_companycode);
                if (company != null)
                {
                    LoginInfo.CompanyInfo = company;
                    initComboBoxByCompany();
                }
            }
            initing = false;
        }
Exemplo n.º 18
0
        public async Task <CompanyModel> CreateCompany(AuthorizedDto <CompanyDto> model)
        {
            return(await Execute(async() => {
                using (UnitOfWork db = new UnitOfWork())
                {
                    CompanyEntity company = model.Data.ToModel <CompanyModel>().ToEntity <CompanyEntity>();

                    company.Owner = await db.GetRepo <AccountEntity>().Get(model.Session.UserId);

                    IList <RoleEntity> defaultRoles = await db.GetRepo <RoleEntity>().Get(role => role.is_default);

                    company.Owner.Roles.Remove(defaultRoles.FirstOrDefault(role => role.name == DefaultRoles.AUTHORIZED.ToName()));
                    company.Owner.Roles.Add(defaultRoles.FirstOrDefault(role => role.name == DefaultRoles.OWNER.ToName()));

                    CompanyEntity created = await db.GetRepo <CompanyEntity>().Create(company);
                    company.Owner.Company = created;

                    await db.Save();

                    await RoleService.CreateCompanyOwnerRole(company.owner_id);

                    return await GetCompany(created.owner_id);
                }
            }));
        }
Exemplo n.º 19
0
        // Google map popup on clicking the location from Search Data
        public ActionResult GoogleMapPopUp()
        {
            MainMatchEntity objmainMatchEntity = new MainMatchEntity();

            objmainMatchEntity.lstMatches = JsonConvert.DeserializeObject <List <MatchEntity> >(SessionHelper.SearchMatch);
            if (objmainMatchEntity.lstMatches == null)
            {
                objmainMatchEntity.lstMatches = new List <MatchEntity>();
            }
            CompanyEntity Company = new CompanyEntity();

            Company.Matches = objmainMatchEntity.lstMatches;

            SearchModel objmodel = new SearchModel();

            objmodel = JsonConvert.DeserializeObject <SearchModel>(SessionHelper.SearchModel);
            if (objmodel != null)
            {
                Company.CompanyName          = objmodel.CompanyName;
                Company.Address              = objmodel.Address;
                Company.Address1             = objmodel.Address2;
                Company.City                 = objmodel.City;
                Company.State                = objmodel.State;
                Company.PostalCode           = objmodel.Zip;
                Company.CountryISOAlpha2Code = objmodel.Country;
                Company.PhoneNbr             = objmodel.PhoneNbr;
            }
            TempData.Keep();
            return(View("~/Views/StewardshipPortal/GoogleMapPopUp.cshtml", Company));
        }
Exemplo n.º 20
0
        public void DetachProjectFromCompany_GoodWeather()
        {
            var company = new CompanyEntity()
            {
                Name = "MySuccessfulCompany", Description = "Best company ever", Projects = new List <ProjectEntity>()
            };

            _context.Projects.Add(new ProjectEntity()
            {
                Name = "Super-duper project", Description = "The most amazing project ever"
            });

            company.Projects = new List <ProjectEntity>()
            {
                _context.Projects.Find(1)
            };

            _context.Companies.Add(company);
            var res = _controller.GetById(1, 1) as OkNegotiatedContentResult <ProjectResource>;

            Assert.IsNotNull(res);
            Assert.AreEqual("Super-duper project", res.Content.Name);

            res = _controller.Detach(1, 1) as OkNegotiatedContentResult <ProjectResource>;
            Assert.IsNotNull(res);
            Assert.AreEqual("Super-duper project", res.Content.Name);

            var resTwo = _controller.GetById(1, 1);

            Assert.IsNotNull(resTwo);
            Assert.IsInstanceOf <NotFoundResult>(resTwo);
        }
Exemplo n.º 21
0
        public virtual ActionResult Save(CompanyModel model)
        {
            if (model == null)
            {
                return(null);
            }
            var           company = GetCompany();
            CompanyEntity entity  = null;

            if (company == null)
            {
                entity      = model.CreateEntity(SaveType.Add);
                entity.Site = new SiteEntity {
                    Id = SiteId
                };
            }
            else
            {
                entity    = model.CreateEntity(SaveType.Modify);
                entity.Id = company.Id;
            }
            var result = new Dictionary <string, object>();

            entity.Site = new SiteEntity {
                Id = SiteId
            };
            var rev  = this.SaveEntity(entity);
            var mess = rev ? "" : entity.Errors?.FirstOrDefault()?.Message;

            result.Add("Status", rev);
            result.Add("Message", mess);
            return(this.Jsonp(result));
        }
Exemplo n.º 22
0
 public CompanyDto(CompanyEntity companyEntity)
 {
     Name      = companyEntity.Name;
     Profile   = companyEntity.Profile == null ? null : new ProfileDto(companyEntity.Profile);
     Employees = companyEntity.Employees?.
                 Select(employeeEntity => new EmployeeDto(employeeEntity)).ToList();
 }
Exemplo n.º 23
0
        public static async Task <IActionResult> RunCreate(
            [HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "companies")] Company company,
            [Table(CompanyEntity.TABLE_NAME, Connection = "storageConnectionString")] CloudTable table,
            ILogger log)
        {
            if (company == null || company.Address == null)
            {
                return(new BadRequestResult());
            }

            var entity = new CompanyEntity
            {
                AcceptedTerms     = company.AcceptedTerms,
                City              = company.Address.City,
                CompanyName       = company.CompanyName,
                CopyAcceptedTerms = company.CopyAcceptedTerms,
                Email             = company.Email,
                Firstname         = company.ContactFirstName,
                HouseNumber       = company.Address.HouseNumber,
                IBAN              = company.IBAN,
                Lastname          = company.ContactLastName,
                Latitude          = company.Address.Latitude,
                Longitude         = company.Address.Longitude,
                RowKey            = await GenerateSlugAsync(company, table),
                Street            = company.Address.Street,
                Zipcode           = company.Address.Zipcode
            };
            await table.ExecuteAsync(TableOperation.Insert(entity));

            company.Slug = entity.Slug;

            return(new OkObjectResult(company));
        }
Exemplo n.º 24
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (!BeforSave())
            {
                return;
            }
            CompanyEntity entity = new CompanyEntity();
            DataRow       dr     = entity.Tables[entity.TableName].NewRow();

            if (_id > 0)
            {
                dr[CompanyEntity.FIELD_ID] = _id;
            }

            dr[CompanyEntity.FIELD_COMPANY_NAME] = txtCompanyName.Text;
            dr[CompanyEntity.FIELD_TEL]          = txtTel.Text;
            dr[CompanyEntity.FIELD_SEMAT]        = ((ComboBoxItem)cmbSemat.Items[cmbSemat.SelectedIndex]).Value;
            dr[CompanyEntity.FIELD_OFFICER]      = txtOfficer.Text;
            dr[CompanyEntity.FIELD_FAX]          = txtFax.Text;
            dr[CompanyEntity.FIELD_ADDRESS]      = txtAddress.Text;
            dr[CompanyEntity.FIELD_DESCRIPTION]  = txtDescription.Text;
            dr[CompanyEntity.FIELD_ACTIVE]       = (cmbActive.SelectedIndex == 1? false : true);
            entity.Tables[entity.TableName].Rows.Add(dr);

            if (_id < 0)
            {
                _id         = _companyBL.add(entity);
                lblMsg.Text = "دخیره شده ";
            }
            else
            {
                _companyBL.update(entity);
                lblMsg.Text = "به روز رسانی گردید.";
            }
        }
Exemplo n.º 25
0
        public static IActionResult RunGet(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "companies/{slug}")] HttpRequest req,
            [Table(CompanyEntity.TABLE_NAME, Constants.PARTITIONKEY_COMPANY, "{slug}", Connection = "storageConnectionString")] CompanyEntity companyEntity,
            ILogger log)
        {
            if (companyEntity == null)
            {
                return(new NotFoundResult());
            }

            var company = new Company
            {
                AcceptedTerms = companyEntity.AcceptedTerms,
                Address       = new Address
                {
                    City        = companyEntity.City,
                    HouseNumber = companyEntity.HouseNumber,
                    Latitude    = companyEntity.Latitude,
                    Longitude   = companyEntity.Longitude,
                    Street      = companyEntity.Street,
                    Zipcode     = companyEntity.Zipcode
                },
                CompanyName       = companyEntity.CompanyName,
                ContactFirstName  = companyEntity.Firstname,
                ContactLastName   = companyEntity.Lastname,
                CopyAcceptedTerms = companyEntity.CopyAcceptedTerms,
                Email             = companyEntity.Email,
                IBAN = companyEntity.IBAN,
                Slug = companyEntity.RowKey
            };

            return(new OkObjectResult(company));
        }
        public void Delete(CompanyEntity entityObject)
        {
            if (ShowMessageBox(StringResources.captionConfirm, StringResources.msgConfirmDelete, MessageBoxButton.YesNo) == MessageBoxResult.Yes)
            {
                System.Threading.ThreadPool.QueueUserWorkItem(delegate
                {
                    try
                    {
                        ShowLoading(StringResources.captionInformation, StringResources.msgLoading);

                        var updatedEntity = Factory.Resolve <ICompanyDS>().DeleteCompany(entityObject);

                        HideLoading();

                        //display to UI
                        Application.Current.Dispatcher.Invoke(new Action(() =>
                        {
                            DeleteCompany(entityObject);
                            SelectedCompany = null;
                        }));
                    }
                    catch (Exception ex)
                    {
                        HideLoading();
                        ShowMessageBox(StringResources.captionError, ex.ToString(), MessageBoxButton.OK);
                    }
                });
            }
        }
        public void FromCompanyEntityToDTO()
        {
            //Given an AdressEntity
            CompanyEntity companyEntity = new CompanyEntity
            {
                Name            = "CompanyName Test",
                DefaultCurrency = "ILS",
                WebSite         = "www.testWebSite.com",
                Phone1          = "05489988-545-566",
                Fax             = "126523s23s323s",
                Email           = "*****@*****.**",
                Address         = new Address
                {
                    ID          = "Addr W",
                    Country     = "IL",
                    City        = " W city",
                    Block       = " W block",
                    Street      = " W street",
                    NumAtStreet = " W numAtSteet",
                    Apartment   = " W Apartment",
                    ZipCode     = " W ZipCode"
                }
            };

            //When converting the entity to DTO and than back to an entity
            CompanyEntity companyEntityAfterConver = _mapper.Map <CompanyEntity>(_mapper.Map <CompanyDto>(companyEntity));

            //Than the entity after the convert should match the entity before
            companyEntityAfterConver.Should().BeEquivalentTo(companyEntity, options => options.IncludingNestedObjects());
            //and the entity after the convert should not be the  entity before
            companyEntityAfterConver.Should().NotBeSameAs(companyEntity);
        }
Exemplo n.º 28
0
        public async Task UpdateCompany(CompanyEntity companyEntity)
        {
            var existingCompanyEntity = await GetCompanyEntity(companyEntity.Id);

            existingCompanyEntity.Name       = companyEntity.Name;
            existingCompanyEntity.ActivityId = companyEntity.ActivityId;
        }
Exemplo n.º 29
0
        private void UpdatePipelineItemPlacements(
            CompanyEntity company, ICollection <PipelineItemEntity> pipelineItems,
            ICollection <PipelineItemPlacementDto> pipelineItemPlacements
            )
        {
            foreach (PipelineItemPlacementDto pipelineItemPlacement in pipelineItemPlacements)
            {
                PipelineItemEntity pipelineItemEntity = pipelineItems.FirstOrDefault(
                    pi => pi.id == pipelineItemPlacement.PipelineItemId.Value
                    );

                ManufactoryEntity manufactoryPlacement = GetManufactoryByPoint(
                    company, pipelineItemPlacement.X.Value, pipelineItemPlacement.Y.Value
                    );

                if (manufactoryPlacement == null)
                {
                    throw new PlacementException();
                }

                pipelineItemEntity.manufactory_id = manufactoryPlacement.id;
                pipelineItemEntity.x = pipelineItemPlacement.X;
                pipelineItemEntity.y = pipelineItemPlacement.Y;
            }
        }
Exemplo n.º 30
0
        public async Task <CompanyEntity> Create(CompanyEntity company)
        {
            _context.Companies.Add(company);
            await _context.SaveChangesAsync();

            return(company);
        }
        public CompanyStoreResponse Store(CompanyStoreRequest request)
        {
            var company =
                _dbContext.CompanyEntities.FirstOrDefault(
                    c => string.Compare(c.Symbol, request.Symbol, StringComparison.InvariantCultureIgnoreCase) == 0);

            if (company == null)
            {
                company = new CompanyEntity() {Symbol = request.Symbol};
                _dbContext.CompanyEntities.Add(company);
            }

            company.Name = request.Name;
            company.Sector = request.Sector;
            company.Industry = request.Industry;
            company.IPOyear = request.IPOyear;
            company.LastSale = (decimal?) request.LastSale;
            company.MarketCap = (decimal?) request.MarketCap;
            company.SummaryQuoteUrl = request.SummaryUrl;
            company.ADR_TSO = request.AdrTso;

            _dbContext.SaveChanges();

            return new CompanyStoreResponse
            {
                Item = Mapper.Map<Company>(company)
            };
        }