public async Task <ActionResult <ParentCompany> > PostParentCompany(ParentCompany parentCompany)
        {
            _context.ParentCompanies.Add(parentCompany);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetParentCompany", new { id = parentCompany.ParentCompanyId }, parentCompany));
        }
        public async Task <IActionResult> PutParentCompany(int id, ParentCompany parentCompany)
        {
            if (id != parentCompany.ParentCompanyId)
            {
                return(BadRequest());
            }

            _context.Entry(parentCompany).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ParentCompanyExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Title")] ParentCompany parentCompany)
        {
            if (id != parentCompany.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(parentCompany);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ParentCompanyExists(parentCompany.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(parentCompany));
        }
        public void Snapshot(Writer writer)
        {
            if (SnapshotIdentity == writer.SnapshotIdentity)
            {
                return;
            }
            SnapshotIdentity = writer.SnapshotIdentity;
            SnapshotObjectId = writer.GetNextObjectId();

            //Collections
            //Dictionaries
            foreach (var user in _users.Values)
            {
                user.Snapshot(writer);
            }

            //Referenced Snapshot Items
            ParentCompany?.Snapshot(writer);

            //Snapshot Object
            writer.WriteClassStart("SnapshotTestingGround.ModelClasses.ExternalCompany");
            writer.WriteProperty("SnapshotObjectId", SnapshotObjectId);
            writer.WriteProperty("_id", _id.WriteSnapshotValue());
            writer.WriteProperty("Name", Name.WriteSnapshotValue());
            writer.WriteArray("Users",
                              Users.Select(kp => new KeyValuePair <string, string>(kp.Key.WriteSnapshotValue(),
                                                                                   kp.Value.SnapshotObjectId.WriteSnapshotValue()).WriteSnapshotValue()));
            writer.WriteProperty("ParentCompanyId", ParentCompany?.SnapshotObjectId);
            writer.WriteClassEnd();
        }
        public async Task <IActionResult> Create([Bind("Id,Title")] ParentCompany parentCompany)
        {
            if (ModelState.IsValid)
            {
                _context.Add(parentCompany);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(parentCompany));
        }
Exemplo n.º 6
0
 public void SetUp()
 {
     this.transactionScope           = new TransactionScope();
     this.authoriseHistoryRepository = new AuthoriseHistoryRepository(ConfigurationManager.ConnectionStrings["BBOS"].ConnectionString);
     this.jobRepository     = new JobRepository(ConfigurationManager.ConnectionStrings["BBOS"].ConnectionString);
     this.job               = BuildMeA.Job(DateTime.Now, DateTime.Now, DateTime.Now, "jwelkjwejwe", "grid");
     this.managementCompany = BuildMeA.ManagementCompany("manconame", "mancocode", "mancoshortname", "rufudbid");
     this.manCoDoc          = BuildMeA.ManCoDoc(2, 3, "Pub file name", "version", 2);
     this.parentCompany     = BuildMeA.ParentCompany("parent company name");
     this.managementCompany.ParentCompany = this.parentCompany;
     this.user     = BuildMeA.ApplicationUser("user");
     this.job.User = this.user;
 }
Exemplo n.º 7
0
        /// <summary>
        /// Все головные компании.
        /// </summary>
        /// <returns></returns>
        public IEnumerable <Company> ParentCompanies()
        {
            if (ParentCompany == null)
            {
                yield break;
            }

            yield return(ParentCompany);

            foreach (var parentCompany in ParentCompany.ParentCompanies())
            {
                yield return(parentCompany);
            }
        }