// Update the existing data in the data base
 public void UpdateEmployee(OrganizationDetails Employee)
 {
     try
     {
         db.Entry(Employee).State = EntityState.Modified;
         db.SaveChanges();
     }
     catch
     {
         throw;
     }
 }
示例#2
0
 public string AverageQuotesFromAllOrgs(List <string> organizations)
 {
     try
     {
         OrganizationDetails        organization        = new OrganizationDetails();
         List <OrganizationDetails> organizationDetails = GetOrganizationDetails(organizations);
         Decimal avgPercantage = (organizationDetails.Sum(x => x.changesPercentage).Value) / organizationDetails.Count;
         return(Math.Round(avgPercantage, 4).ToString());
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 // To delete an entry from the data base
 public void DeleteEmployee(int id)
 {
     try
     {
         OrganizationDetails Employee = db.Organization.Find(id);
         db.Organization.Remove(Employee);
         DeleteChildEmployee(id);
         db.Organization.RemoveRange(EmployeeList);
         db.SaveChanges();
     }
     catch
     {
         throw;
     }
 }
示例#4
0
        public ActionResult Details(int id)
        {
            OrganizationDetails details = _organizationRepository.GetOrganizationDetails(UserContext.User.Id, UserContext.User.OrganizationId, id);

            if (details.Detail == null)
            {
                return(NotFoundResult());
            }

            OrganizationDetailsViewModel viewModel = Mapper.Map <OrganizationDetailsViewModel>(details);

            InitDetailsViewModel(viewModel, details);

            return(View(Mvc.View.Organization.Details, viewModel));
        }
        internal static KeyVaultCertificateOrganizationDetails FromOrganizationalDetails(OrganizationDetails organizationalDetails)
        {
            if (organizationalDetails == null)
            {
                return null;
            }

            var kvcOrganizationDetails = new KeyVaultCertificateOrganizationDetails
            {
                Id = organizationalDetails.Id,
                AdministratorDetails = KeyVaultCertificateAdministratorDetails.FromAdministratorDetails(organizationalDetails.AdminDetails),
            };

            return kvcOrganizationDetails;
        }
 // Adds the new entry to the data base
 public void AddEmployee(OrganizationDetails Employee)
 {
     try
     {
         db.Organization.Add(Employee);
         OrganizationDetails ParentDetails = db.Organization.Find(Employee.ParentId);
         if (ParentDetails != null)
         {
             ParentDetails.HasTeam = true;
         }
         db.SaveChanges();
     }
     catch
     {
         throw;
     }
 }
示例#7
0
        public async Task Can_populate_users()
        {
            var user     = new User();
            var request  = new OrganizationDetailsQuery(42);
            var response = new OrganizationDetails
            {
                Organization = new Organization {
                    GroupName = "foo"
                }
            };

            userRepository.FindByOrganization(Arg.Any <string>())
            .Returns(new [] { user });

            await handler.Handle(request, response);

            Assert.IsTrue(response.Users.Contains(user));
        }
示例#8
0
        public async Task Can_populate_it_contact()
        {
            var user     = new User();
            var request  = new OrganizationDetailsQuery(42);
            var response = new OrganizationDetails
            {
                Organization = new Organization {
                    ITConactSamAccountName = "foo"
                }
            };

            userRepository.FindByUser(Arg.Any <string>())
            .Returns(user);

            await handler.Handle(request, response);

            Assert.AreEqual(response.ITContact, user);
        }
示例#9
0
        public string GetMaximumQuotePrice(List <string> organizations)
        {
            try
            {
                OrganizationDetails        organization        = new OrganizationDetails();
                List <OrganizationDetails> organizationDetails = GetOrganizationDetails(organizations);

                organization = organizationDetails.OrderByDescending(x => x.price).FirstOrDefault();
                //avgPercantage = (organizationDetails.Sum(x => x.changesPercentage).Value) / organizationDetails.Count;
                //responseClass.MaxPriceOrganizationDetails = organization;
                //responseClass.AvgChangesPercentage = Math.Round(avgPercantage, 4);
                return(organization.price.ToString());
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#10
0
        public ActionResult Edit(int id)
        {
            OrganizationDetails details = _organizationRepository.GetOrganizationDetails(UserContext.User.Id, UserContext.User.OrganizationId, id);

            if (details.Detail == null)
            {
                return(NotFoundResult());
            }

            OrganizationDetailsViewModel viewModel = Mapper.Map <OrganizationDetailsViewModel>(details);

            InitDetailsViewModel(viewModel, details);
            viewModel.HeadIds      = viewModel.Heads.Select(m => m.Key).ToList();
            viewModel.DeputyIds    = viewModel.Deputies.Select(m => m.Key).ToList();
            viewModel.MainJudgeIds = viewModel.MainJudges.Select(m => m.Key).ToList();
            viewModel.JudgeIds     = viewModel.Judges.Select(m => m.Key).ToList();
            viewModel.SecretaryIds = viewModel.Secretaries.Select(m => m.Key).ToList();
            viewModel.CashierIds   = viewModel.Cashiers.Select(m => m.Key).ToList();

            return(View(Mvc.View.Organization.Edit, viewModel));
        }
示例#11
0
        private void InitDetailsViewModel(OrganizationDetailsViewModel viewModel, OrganizationDetails details)
        {
            InitBaseDetailViewModel(details.Detail, viewModel.Detail);
            InitBaseDetailEntityStateChange(viewModel.Detail);
            ViewData[Mvc.ViewData.Controller] = Mvc.Controller.Organization.Name;

            viewModel.Heads = details
                              .OrganizationMemberTypes
                              .Where(om => om.OrganizationId == details.Detail.Id && om.MemberTypeId == Dom.MemberType.Head)
                              .ToDictionary(t => t.MemberId, t => Format.FormattedInitials(t.LastName, t.FirstName, t.MiddleName));
            viewModel.Deputies = details
                                 .OrganizationMemberTypes
                                 .Where(om => om.OrganizationId == details.Detail.Id && om.MemberTypeId == Dom.MemberType.Deputy)
                                 .ToDictionary(t => t.MemberId, t => Format.FormattedInitials(t.LastName, t.FirstName, t.MiddleName));
            viewModel.MainJudges = details
                                   .OrganizationMemberTypes
                                   .Where(om => om.OrganizationId == details.Detail.Id && om.MemberTypeId == Dom.MemberType.MainJudge)
                                   .ToDictionary(t => t.MemberId, t => Format.FormattedInitials(t.LastName, t.FirstName, t.MiddleName));
            viewModel.Judges = details
                               .OrganizationMemberTypes
                               .Where(om => om.OrganizationId == details.Detail.Id && om.MemberTypeId == Dom.MemberType.Judge)
                               .ToDictionary(t => t.MemberId, t => Format.FormattedInitials(t.LastName, t.FirstName, t.MiddleName));
            viewModel.Secretaries = details
                                    .OrganizationMemberTypes
                                    .Where(om => om.OrganizationId == details.Detail.Id && om.MemberTypeId == Dom.MemberType.Secretary)
                                    .ToDictionary(t => t.MemberId, t => Format.FormattedInitials(t.LastName, t.FirstName, t.MiddleName));
            viewModel.Cashiers = details
                                 .OrganizationMemberTypes
                                 .Where(om => om.OrganizationId == details.Detail.Id && om.MemberTypeId == Dom.MemberType.Cashier)
                                 .ToDictionary(t => t.MemberId, t => Format.FormattedInitials(t.LastName, t.FirstName, t.MiddleName));

            viewModel.HeadItems      = Mapper.Map <ICollection <SelectListItem> >(details.Members);
            viewModel.DeputyItems    = Mapper.Map <ICollection <SelectListItem> >(details.Members);
            viewModel.MainJudgeItems = Mapper.Map <ICollection <SelectListItem> >(details.Members);
            viewModel.JudgeItems     = Mapper.Map <ICollection <SelectListItem> >(details.Members);
            viewModel.SecretaryItems = Mapper.Map <ICollection <SelectListItem> >(details.Members);
            viewModel.CashierItems   = Mapper.Map <ICollection <SelectListItem> >(details.Members);
        }
示例#12
0
        public ActionResult Edit(OrganizationDetailsViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                var organization = _organizationRepository.Get <Organization>(viewModel.Detail.Id);
                organization.Name        = viewModel.Detail.Name;
                organization.Description = viewModel.Detail.Description;
                organization.CreateDate  = viewModel.Detail.CreateDate;
                if (!string.IsNullOrWhiteSpace(viewModel.Address?.FormattedAddress))
                {
                    if (organization.AddressId != null)
                    {
                        organization.Address.City             = viewModel.Address.City;
                        organization.Address.PostalCode       = viewModel.Address.PostalCode;
                        organization.Address.Street           = viewModel.Address.Street;
                        organization.Address.Number           = viewModel.Address.Number;
                        organization.Address.Latitude         = double.Parse(viewModel.Address.Latitude.Replace(".", ","));
                        organization.Address.Longitude        = double.Parse(viewModel.Address.Longitude.Replace(".", ","));
                        organization.Address.FormattedAddress = viewModel.Address.FormattedAddress;
                    }
                    else
                    {
                        organization.Address = new Address
                        {
                            CountryId        = Dom.Country.Ukraine,
                            City             = viewModel.Address.City,
                            PostalCode       = viewModel.Address.PostalCode,
                            Street           = viewModel.Address.Street,
                            Number           = viewModel.Address.Number,
                            Latitude         = double.Parse(viewModel.Address.Latitude.Replace(".", ",")),
                            Longitude        = double.Parse(viewModel.Address.Longitude.Replace(".", ",")),
                            FormattedAddress = viewModel.Address.FormattedAddress
                        };
                    }
                }
                else
                {
                    if (organization.AddressId != null)
                    {
                        _organizationRepository.Delete(organization.Address);
                        organization.AddressId = null;
                    }
                }
                if (!string.IsNullOrWhiteSpace(viewModel.Website?.Url))
                {
                    if (organization.WebsiteId != null)
                    {
                        organization.Website.Url = viewModel.Website.Url;
                    }
                    else
                    {
                        organization.Website = new Website
                        {
                            Url = viewModel.Website.Url,
                        };
                    }
                }
                else
                {
                    if (organization.WebsiteId != null)
                    {
                        _organizationRepository.Delete(organization.Website);
                        organization.WebsiteId = null;
                    }
                }

                if (organization.OrganizationMemberTypes != null)
                {
                    organization.OrganizationMemberTypes.ToList().ForEach(x => _organizationRepository.Delete(x));
                }
                else
                {
                    organization.OrganizationMemberTypes = new List <OrganizationMemberType>();
                }

                viewModel.HeadIds?.ForEach(m => organization.OrganizationMemberTypes.Add(new OrganizationMemberType {
                    MemberId = m, MemberTypeId = Dom.MemberType.Head
                }));
                viewModel.DeputyIds?.ForEach(m => organization.OrganizationMemberTypes.Add(new OrganizationMemberType {
                    MemberId = m, MemberTypeId = Dom.MemberType.Deputy
                }));
                viewModel.MainJudgeIds?.ForEach(m => organization.OrganizationMemberTypes.Add(new OrganizationMemberType {
                    MemberId = m, MemberTypeId = Dom.MemberType.MainJudge
                }));
                viewModel.JudgeIds?.ForEach(m => organization.OrganizationMemberTypes.Add(new OrganizationMemberType {
                    MemberId = m, MemberTypeId = Dom.MemberType.Judge
                }));
                viewModel.SecretaryIds?.ForEach(m => organization.OrganizationMemberTypes.Add(new OrganizationMemberType {
                    MemberId = m, MemberTypeId = Dom.MemberType.Secretary
                }));
                viewModel.CashierIds?.ForEach(m => organization.OrganizationMemberTypes.Add(new OrganizationMemberType {
                    MemberId = m, MemberTypeId = Dom.MemberType.Cashier
                }));

                _organizationRepository.UnitOfWork.SaveChanges();
                return(RedirectToAction(Mvc.Controller.Organization.Details, Mvc.Controller.Organization.Name, new { id = viewModel.Detail.Id }));
            }

            OrganizationDetails details = _organizationRepository.GetOrganizationDetails(UserContext.User.Id, UserContext.User.OrganizationId, viewModel.Detail.Id);

            InitDetailsViewModel(viewModel, details);

            return(View(Mvc.View.Organization.Edit, viewModel));
        }
        internal static KeyVaultCertificateOrganizationDetails FromOrganizationalDetails(OrganizationDetails organizationalDetails)
        {
            if (organizationalDetails == null)
            {
                return(null);
            }

            var kvcOrganizationDetails = new KeyVaultCertificateOrganizationDetails
            {
                Id = organizationalDetails.Id,
                AdministratorDetails = KeyVaultCertificateAdministratorDetails.FromAdministratorDetails(organizationalDetails.AdminDetails),
            };

            return(kvcOrganizationDetails);
        }
示例#14
0
 public object Put([FromBody] OrganizationDetails employee)
 {
     db.UpdateEmployee(employee);
     return(employee);
 }
示例#15
0
 public void Post([FromBody] OrganizationDetails employee)
 {
     db.AddEmployee(employee);
 }