Example #1
0
        public async void EditCompanyHistory(long HistoryID = 0)
        {
            var newHistoryDialog = new HistoryDialog(); //Create new input dialog

            if (HistoryID != 0)
            {
                selectedCompanyHistory = DataAccessLayer.getCompanyHistoryByID(HistoryID); //Get company history
                newHistoryDialog.SecondaryButtonText = "Delete";                           //Set secondary option
            }
            else
            {
                selectedCompanyHistory = new CompanyHistory();            //Create new history
                selectedCompanyHistory.companyHistoryDate = DateTime.Now; //Set date to today
                newHistoryDialog.SecondaryButtonText      = "Cancel";     //Set secondary option
            }

            var result = await newHistoryDialog.ShowAsync();                       //Show dialog & await result

            if (result == ContentDialogResult.Primary)                             //If primary option chosen
            {
                var item = newHistoryDialog.Content;                               //Get user input
                selectedCompanyHistory.companyHistoryDetails = item.ToString();    //Convert to string
                selectedCompanyHistory.companyID             = selectedCompany.ID; //Attribute company
                DataAccessLayer.saveHistory(selectedCompanyHistory);               //Save history
                GetHistory(selectedCompany.ID);                                    //Refresh history
            }
            else if (result == ContentDialogResult.Secondary)                      //If secondary option chosen
            {
                if (HistoryID != 0)
                {
                    DataAccessLayer.deleteHistory(selectedCompanyHistory);
                    GetHistory(selectedCompany.ID); //Refresh history
                }
            }
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,CompanyId,Name,Content,Date")] CompanyHistory companyHistory)
        {
            if (id != companyHistory.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(companyHistory);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CompanyHistoryExists(companyHistory.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(companyHistory));
        }
        public async Task <IActionResult> Create([Bind("Id,CompanyId,Name,Content,Date")] CompanyHistory companyHistory)
        {
            if (ModelState.IsValid)
            {
                _context.Add(companyHistory);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(companyHistory));
        }
//[ValidateAntiForgeryToken]
        public async Task <IActionResult> Create([Bind("Id,CompanyId,Name,Content,Date")] CompanyHistory companyHistory)
        {
            if (ModelState.IsValid)
            {
                _context.Add(companyHistory);
                await _context.SaveChangesAsync();

                return(Ok());
            }
            return(new JsonResult(companyHistory));
        }
Example #5
0
    public void SaveCompanyHistory(Jury jury, CompanyHistory compnyHistroy, string DateCreated = "")
    {
        if (!string.IsNullOrEmpty(DateCreated) && !compnyHistroy.IsNew)
        {
            compnyHistroy.DateCreatedString = DateCreated;
        }
        else
        {
            compnyHistroy.JuryId      = jury.Id;
            compnyHistroy.Type        = jury.Type;
            compnyHistroy.Designation = jury.Designation;
            compnyHistroy.Company     = jury.Company;
            compnyHistroy.Address1    = jury.Address1;
            compnyHistroy.Address2    = jury.Address2;
            compnyHistroy.City        = jury.City;
            compnyHistroy.Postal      = jury.Postal;
            compnyHistroy.Country     = jury.Country;

            if (DateCreated == "Empty")
            {
                compnyHistroy.DateCreatedString = jury.DateCreatedString;
            }
            else if (!string.IsNullOrEmpty(DateCreated))
            {
                compnyHistroy.DateCreatedString = DateCreated;
            }

            compnyHistroy.CompanyType      = jury.CompanyType;
            compnyHistroy.CompanyTypeOther = jury.CompanyTypeOther;

            compnyHistroy.Network = jury.Network;
            if (compnyHistroy.Network == "Others")
            {
                compnyHistroy.NetworkOthers = jury.NetworkOthers.Trim();
            }

            compnyHistroy.HoldingCompany = jury.HoldingCompany;
            if (compnyHistroy.HoldingCompany == "Others")
            {
                compnyHistroy.HoldingCompanyOthers = jury.HoldingCompanyOthers.Trim();
            }
        }

        compnyHistroy.Save();

        string msg = "JURY ID : " + jury.Id + " || CompnyHistroy ID : " + compnyHistroy.Id + " || IsNew : " + compnyHistroy.IsNew + " || DateCreated : " + DateCreated + "<br>";

        Response.Write(msg);
    }
Example #6
0
        /// <summary>
        /// Converts this instance of <see cref="CompanyHistory"/> to an instance of <see cref="CompanyHistoryDTO"/>.
        /// </summary>
        /// <param name="entity"><see cref="CompanyHistory"/> to convert.</param>
        public static CompanyHistoryDTO ToDTO(this CompanyHistory entity)
        {
            if (entity == null)
            {
                return(null);
            }

            var dto = new CompanyHistoryDTO();

            dto.ID               = entity.ID;
            dto.CompanyID        = entity.CompanyID;
            dto.Name             = entity.Name;
            dto.ModifiedByUserID = entity.ModifiedByUserID;
            dto.ModifiedDate     = entity.ModifiedDate;
            entity.OnDTO(dto);

            return(dto);
        }
Example #7
0
        /// <summary>
        /// Converts this instance of <see cref="CompanyHistoryDTO"/> to an instance of <see cref="CompanyHistory"/>.
        /// </summary>
        /// <param name="dto"><see cref="CompanyHistoryDTO"/> to convert.</param>
        public static CompanyHistory ToEntity(this CompanyHistoryDTO dto)
        {
            if (dto == null)
            {
                return(null);
            }

            var entity = new CompanyHistory();

            entity.ID               = dto.ID;
            entity.CompanyID        = dto.CompanyID;
            entity.Name             = dto.Name;
            entity.ModifiedByUserID = dto.ModifiedByUserID;
            entity.ModifiedDate     = dto.ModifiedDate;
            dto.OnEntity(entity);

            return(entity);
        }
Example #8
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        JuryList JuryLists = JuryList.GetJuryList("", "");

        foreach (Jury jury in JuryLists)
        {
            List <CompanyHistory> companies = CompanyHistoryList.GetCompanyHistoryList(jury.Id).OrderByDescending(x => x.DateCreated).ToList();
            if (companies.Count > 0)
            { //EDIT HERE
                int            count = 1;
                CompanyHistory CurrCompanyHistory = null;
                //EDIT DATE CREATED
                foreach (CompanyHistory com in companies)
                {
                    if (count == 1)
                    {
                        //NEW COMPANY HISTORY
                        CompanyHistory compnyHistroy = CompanyHistory.NewCompanyHistory();
                        SaveCompanyHistory(jury, compnyHistroy, com.DateCreatedString);
                    }
                    else
                    {
                        SaveCompanyHistory(jury, CurrCompanyHistory, com.DateCreatedString);
                    }

                    if (count != companies.Count || companies.Count == 1)
                    {
                        CurrCompanyHistory = com;
                    }

                    count++;
                }

                //FOR LATEST COMPANY HISTORY
                SaveCompanyHistory(jury, CurrCompanyHistory, jury.DateCreatedString);
            }
            else
            {   //NEW COMPANY HISTORY
                CompanyHistory compnyHistroy = CompanyHistory.NewCompanyHistory();
                SaveCompanyHistory(jury, compnyHistroy, "Empty");
            }
        }
    }
Example #9
0
        public void Execute_Creates_History_Record()
        {
            // Setup
            InitializeTestEntities();

            // Act
            DateTime start = DateTime.Now;

            new CreateCompanyCommand(_serviceFactory.Object).WithJobSearch(_search.Id)
            .SetName("Name")
            .SetPhone("555-555-5555")
            .SetCity("City")
            .SetState("State")
            .SetZip("01234")
            .SetMetroArea("Metro")
            .SetIndustry("Industry")
            .SetNotes("Notes")
            .SetWebsite("website")
            .SetJigsawId(1234)
            .CalledByUserId(_user.Id)
            .Execute();
            DateTime end = DateTime.Now;

            // Verify
            Company        company = _unitOfWork.Companies.Fetch().Single();
            CompanyHistory result  = company.History.Single();

            Assert.IsNotNull(result, "No history record was created");
            Assert.AreEqual("Name", result.Name, "The created history record's name was incorrect");
            Assert.AreEqual("555-555-5555", result.Phone, "The created history record's phone number was incorrect");
            Assert.AreEqual("City", result.City, "The created history record's city was incorrect");
            Assert.AreEqual("State", result.State, "The created history record's state was incorrect");
            Assert.AreEqual("01234", result.Zip, "The created history record's zip was incorrect");
            Assert.AreEqual("Metro", result.MetroArea, "The created history record's metro area was incorrect");
            Assert.AreEqual("Notes", result.Notes, "The created history record's notes were incorrect");
            Assert.AreEqual(1234, result.JigsawId, "Jigsaw Id was incorrect");
            Assert.AreEqual("website", result.Website, "Website was incorrect");
            Assert.AreEqual(_user, result.AuthoringUser, "The history record's author was incorrect");
            Assert.AreEqual(MJLConstants.HistoryInsert, result.HistoryAction, "The history record's history action was incorrect");
            Assert.IsTrue(result.DateModified >= start && result.DateModified <= end, "The history record's modification date was incorrect");
        }
        public void Execute_Creates_History_Record()
        {
            // Setup
            InitializeTestEntities();

            // Act
            DateTime start = DateTime.Now;

            new EditCompanyCommand(_serviceFactory.Object).WithCompanyId(_company.Id)
            .SetName("Name")
            .SetPhone("555-555-5555")
            .SetCity("City")
            .SetState("State")
            .SetZip("01234")
            .SetMetroArea("Metro")
            .SetIndustry("Industry")
            .SetNotes("Notes")
            .SetWebsite("site2")
            .RequestedByUserId(_user.Id)
            .Execute();
            DateTime end = DateTime.Now;

            // Verify
            Company        company = _unitOfWork.Companies.Fetch().Single();
            CompanyHistory history = company.History.Single();

            Assert.AreEqual("Name", history.Name, "The history record's name was incorrect");
            Assert.AreEqual("555-555-5555", history.Phone, "The history record's phone number was incorrect");
            Assert.AreEqual("City", history.City, "The history record's city was incorrect");
            Assert.AreEqual("State", history.State, "The history record's state was incorrect");
            Assert.AreEqual("01234", history.Zip, "The history record's zip was incorrect");
            Assert.AreEqual("Metro", history.MetroArea, "The history record's metro area was incorrect");
            Assert.AreEqual("Notes", history.Notes, "The history record's notes were incorrect");
            Assert.AreEqual("Industry", history.Industry, "The history record's industry was incorrect");
            Assert.AreEqual("site2", history.Website, "History record's website was incorrect");
            Assert.AreEqual(1234, history.JigsawId, "The jigsaw id was incorrect");

            Assert.AreEqual(_user, history.AuthoringUser, "The history record's author was incorrect");
            Assert.AreEqual(MJLConstants.HistoryUpdate, history.HistoryAction, "The history record's action value was incorrect");
            Assert.IsTrue(history.DateModified >= start && history.DateModified <= end, "The history record's modification date was incorrect");
        }
Example #11
0
    public void SaveCompanyHistory(Jury jury, ClosedXML.Excel.IXLRangeRow CurrentRow)
    {
        CompanyHistory compnyHistroy = CompanyHistory.NewCompanyHistory();

        compnyHistroy.JuryId      = jury.Id;
        compnyHistroy.Type        = RemoveControlChars(CurrentRow.Cell(2).GetString());
        compnyHistroy.Designation = RemoveControlChars(CurrentRow.Cell(7).GetString());
        compnyHistroy.Company     = RemoveControlChars(CurrentRow.Cell(8).GetString());

        compnyHistroy.Country            = RemoveControlChars(CurrentRow.Cell(17).GetString());
        compnyHistroy.DateModifiedString = DateTime.Now.ToString();
        compnyHistroy.Network            = RemoveControlChars(CurrentRow.Cell(9).GetString());
        compnyHistroy.HoldingCompany     = RemoveControlChars(CurrentRow.Cell(10).GetString());

        if (compnyHistroy.IsNew)
        {
            compnyHistroy.DateCreatedString = DateTime.Now.AddYears(-3).ToString();
        }

        if (compnyHistroy.IsValid)
        {
            compnyHistroy.Save();
        }
    }
Example #12
0
 /// <summary>
 /// Invoked when <see cref="ToEntity"/> operation is about to return.
 /// </summary>
 /// <param name="entity"><see cref="CompanyHistory"/> converted from <see cref="CompanyHistoryDTO"/>.</param>
 static partial void OnEntity(this CompanyHistoryDTO dto, CompanyHistory entity);
Example #13
0
 /// <summary>
 /// Invoked when <see cref="ToDTO"/> operation is about to return.
 /// </summary>
 /// <param name="dto"><see cref="CompanyHistoryDTO"/> converted from <see cref="CompanyHistory"/>.</param>
 static partial void OnDTO(this CompanyHistory entity, CompanyHistoryDTO dto);