Example #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,HoursRequired,Status")] ContractTypes contractTypes)
        {
            if (id != contractTypes.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(contractTypes);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ContractTypesExists(contractTypes.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(contractTypes));
        }
 /// <summary>
 /// COntructor, applies the annual salary formula
 /// </summary>
 /// <param name="hourlySalary"></param>
 /// <param name="monthlySalary"></param>
 public EmployeeMonthlySalary(decimal hourlySalary, decimal monthlySalary)
 {
     _contractType = ContractTypes.MonthlySalaryEmployee;
     HourlySalary  = hourlySalary;
     MonthlySalary = monthlySalary;
     _annualSalary = MonthlySalary * 12;
 }
Example #3
0
 public async void OnContractChanged(ContractTypes oldContract, ContractTypes newContract)
 {
     if (contractTypeChanged != null)
     {
         contractTypeChanged(this, new ContractEventArgs()
         {
             oldContract = oldContract, newContract = newContract
         });
     }
 }
Example #4
0
        public async Task <IActionResult> Create([Bind("Id,Name,HoursRequired,Status")] ContractTypes contractTypes)
        {
            if (ModelState.IsValid)
            {
                _context.Add(contractTypes);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(contractTypes));
        }
Example #5
0
 public Werknemers(string name, DateTime bornDate, string rRN, string sex, double bruttoLoon = 1900, ContractTypes typeContract = ContractTypes.FuulTime, DateTime dateOfStart)  //hear mijn programma begin te klagen
 {
     Name         = name;
     BornDate     = bornDate;
     RRN          = rRN;
     Sex          = sex;
     BruttoLoon   = bruttoLoon;
     TypeContract = typeContract;
     CompannyCar  = false;
     DateOfStart  = dateOfStart;
     Functie      = "Werknemer";
 }
Example #6
0
        private static string GetSnippet(ContractTypes contractTypes)
        {
            var sb = new StringBuilder();

            sb.AppendLine("class TestClass {");

            sb.AppendLineIf(contractTypes.HasFlag(ContractTypes.Post), "[return: NonNull]");
            sb.Append("public string TestMethod(");
            sb.AppendIf(contractTypes.HasFlag(ContractTypes.Pre), "[NonNull]");
            sb.AppendLine("string text, string output) {");
            sb.AppendLine("return output; } }");
            return(sb.ToString());
        }
Example #7
0
 /// <summary>
 /// Permet de sauvegarder en base de données les changements appliqués au Type de contrat sélectionné
 /// </summary>
 public void SaveContractType()
 {
     try
     {
         ContractTypes.Where(ContractType => ContractType.Identifier.Equals(SelectedContractType.Identifier));
         this.Entities.SaveChanges();
         MyMessageQueue.Enqueue(SelectedContractType.Name + " a bien été modifié !");
     }
     catch
     {
         MyMessageQueue.Enqueue("Wow, une erreur s'est produite !");
     }
 }
 public Werknemer(string naam, Geslachten geslacht, DateTime geboorteDatum, string rijksRegisterNummer, string iban, DateTime datumInDienstTreding, double brutoLoon = 1900, ContractTypes typeContract = ContractTypes.Voltijds)
 {
     FunctieTitel         = "Werknemer";
     Naam                 = naam;
     Geslacht             = geslacht;
     GeboorteDatum        = geboorteDatum;
     Iban                 = iban;
     RijksRegisterNummer  = rijksRegisterNummer;
     BrutoLoon            = brutoLoon;
     TypeContract         = typeContract;
     DatumInDienstTreding = datumInDienstTreding;
     BedrijfsWagen        = false;
     AantalUren           = (typeContract == ContractTypes.Voltijds) ? 38 : AantalUren;
 }
Example #9
0
        private static string GetSnippet(ContractTypes contractTypes, string result = null)
        {
            var sb = new StringBuilder();

            sb.AppendLine("class TestClass {");

            sb.AppendLineIf(contractTypes.HasFlag(ContractTypes.Post), "[return: NonNull]");
            sb.Append("public static explicit operator string(");
            sb.AppendIf(contractTypes.HasFlag(ContractTypes.Pre), "[NonNull]");
            sb.AppendLine("TestClass obj) {");
            sb.AppendLine($"return {(result == null ? "null" : $"\"{result}\"")};");
            sb.AppendLine("} }");
            return(sb.ToString());
        }
        private static string GetMethodSnippet(ContractTypes contractTypes, string result = null)
        {
            var sb = new StringBuilder();

            sb.AppendLine("class TestClass {");

            sb.AppendLineIf(contractTypes.HasFlag(ContractTypes.Post), "[return: NonNull]");
            sb.Append("public string TestMethod(");
            sb.AppendIf(contractTypes.HasFlag(ContractTypes.Pre), "[NonNull]");
            sb.AppendLine("string text) =>");
            sb.Append($"{(result == null ? "null" : $"\"{result}\"")};");
            sb.AppendLine("}");
            return(sb.ToString());
        }
Example #11
0
        public IEnumerable <IAmAnEventMessage> RetrieveFor(string aggregateId)
        {
            var request = new RestRequest($"api/v1/events/{aggregateId}", Method.GET);

            request.AddHeader("x-functions-key", API_KEY);

            var response = _httpClient.Execute <List <EventBag> >(request);

            return(response.Data.Select(eventBag => {
                var eventType = ContractTypes.ResolveByName(eventBag.TypeOfEvent);

                var @event = JSON.Deserialize(eventBag.Event, eventType) as IAmAnEventMessage;
                return @event;
            }));
        }
Example #12
0
        public static string GetSnippet(string attributeName, string typeName, ContractTypes contractTypes)
        {
            var sb = new StringBuilder();

            sb.AppendLine("class TestClass {");

            sb.AppendLineIf(contractTypes.HasFlag(ContractTypes.Post), $"[return: {attributeName}]");

            sb.Append($"public {typeName} TestMethod(");

            sb.AppendIf(contractTypes.HasFlag(ContractTypes.Pre), $"[{attributeName}]");

            sb.AppendLine($"{typeName} value) {{");
            sb.AppendLine("return value; } }");
            return(sb.ToString());
        }
Example #13
0
        public static ContractType Creator(ContractTypes contractType)
        {
            switch (contractType)
            {
            case ContractTypes.HourlySalary:

                return(new HourlyContract());

            case ContractTypes.MonthlySalary:

                return(new MonthlyContract());

            default:
                return(null);
            }
        }
Example #14
0
                public string getContractName(ContractTypes contract)
                {
                    switch (contract)
                    {
                    case ContractTypes.contract:
                        return("Kontrakt");

                    case ContractTypes.fullTime:
                        return("Pełen etat");

                    case ContractTypes.partTime:
                        return("Niepełny etat");

                    default:
                        return("Błędnie wprowadzona informacja o zatrudnieniu");
                    }
                }
Example #15
0
        private static string GetMethodSnippet(ContractTypes contractTypes)
        {
            var sb = new StringBuilder();

            sb.AppendLine("abstract class BaseClass {");
            sb.AppendLineIf(contractTypes.HasFlag(ContractTypes.Post), "[return: NonNull]");
            sb.Append("public abstract string TestMethod(");
            sb.AppendIf(contractTypes.HasFlag(ContractTypes.Pre), "[NonNull]");
            sb.AppendLine("string text);");
            sb.AppendLine("}");

            sb.AppendLine("class TestClass : BaseClass {");
            sb.AppendLine("public override string TestMethod(string text) {");
            sb.AppendLine("return text;");
            sb.AppendLine("}");
            sb.AppendLine("}");
            return(sb.ToString());
        }
Example #16
0
        private static string GetSnippet(ContractTypes contractTypes)
        {
            var sb = new StringBuilder();

            sb.AppendLine("class TestClass {");

            sb.AppendLineIf(contractTypes.HasFlag(ContractTypes.Post), "[return: NonNull]");
            sb.AppendLine("public string TestMethod() {");

            //This lambda's return statement should not be affected.
            sb.AppendLine(@"Func<string> someLambda = () => { return null; };");
            sb.AppendLine(@"var someResult = someLambda();");

            sb.AppendLine(@"return ""text"";");
            sb.AppendLine("}");

            sb.AppendLine("}");
            return(sb.ToString());
        }
Example #17
0
        public string TranslateContractToJobName(ContractTypes Contract)
        {
            string Jobname = "";

            switch (Contract)
            {
            case ContractTypes.FullTime:
                Jobname = "Full Time";
                break;

            case ContractTypes.PartTime:
                Jobname = "Part Time";
                break;

            case ContractTypes.Contract:
                Jobname = "Contract";
                break;
            }
            return(Jobname);
        }
Example #18
0
        private static string GetMethodSnippet(ContractTypes contractTypes, bool explicitImplementation)
        {
            var sb = new StringBuilder();

            sb.AppendLine("interface ITest {");
            sb.AppendLineIf(contractTypes.HasFlag(ContractTypes.Post), "[return: NonNull]");
            sb.Append("string TestMethod(");
            sb.AppendIf(contractTypes.HasFlag(ContractTypes.Pre), "[NonNull]");
            sb.AppendLine("string text);");
            sb.AppendLine("}");

            sb.AppendLine("class TestClass : ITest {");
            sb.AppendIf(!explicitImplementation, "public ");
            sb.Append("string ");
            sb.AppendIf(explicitImplementation, "ITest.");
            sb.AppendLine("TestMethod(string text) {");
            sb.AppendLine("return text;");
            sb.AppendLine("}");
            sb.AppendLine("}");
            return(sb.ToString());
        }
        public void SaveEntityFieldsCopyInContract(ContractTypes entities)
        {
            TopContractsV01Entities context = new TopContractsV01Entities(Utilities.getTestEnvName());
            //long ContractTypeContractsID = ConfigurationProvider.Default.ContractTypeContracts.ContractTypeContractsID;
            long ContractTypeContractsID = Utilities.contractTypeContractsID; // Code implemented by Viplav on 17 june 2013 for remove webconfig concept
            List<long?> recordcounters = new List<long?>();
            TopContractsEntities.FieldGroup entityFieldGroup = null;
            foreach (TopContractsDAL10.SystemTables.ContractType entity in entities.Entries)
            {
                if (context.Fields.Any(fld => fld.LinkedEntityID == entity.ID))
                {
                    if (context.FieldGroupsContractTypesMAPs.Any(f => f.ContractTypeID == entity.ID) && context.FieldGroupsContractTypesMAPs.Count(f => f.ContractTypeID == entity.ID) == 1)
                    {
                        entityFieldGroup = context.FieldGroupsContractTypesMAPs.First(f => f.ContractTypeID == entity.ID).FieldGroup;
                    }
                    // code area to a create a new contract field entry if an entity field has been selected to make a
                    // copy in contract.
                    foreach (ContractTypesFieldsToCreateDefault DefEntFld in entity.DefaultEntityFields.Where(fld => fld.Deleted == false))
                    {
                        //foreach (TopContractsEntities.Contract contract in context.Contracts.Where(c => c.ContractType.ParentContractTypeID == ContractTypeContractsID && c.ContractFields.Any(cf => cf.FieldID == DefEntFld.FieldID) == false))
                        foreach (TopContractsEntities.Contract contract in context.Contracts.Where(c => c.ContractType.ParentContractTypeID == ContractTypeContractsID && c.ContractFields.Any(cf => cf.CatalogFieldID == DefEntFld.FieldID) == false))
                        {
                            foreach (TopContractsEntities.Field field in context.Fields.Where(fg => fg.LinkedEntityID == DefEntFld.ContractTypeID))
                            {
                                //if (contract.ContractFields.Any(cf => cf.FieldID == DefEntFld.FieldID && cf.FieldGroupID == fieldGroupId) == false)
                                if (contract.ContractFields.Any(cf => cf.CatalogFieldID == DefEntFld.FieldID && cf.FieldGroupID == field.FieldGroupID) == false)
                                {
                                    recordcounters = contract.ContractFields.Where(fg => fg.FieldGroupID == field.FieldGroupID).Select(c => c.RecordCounter).Distinct().ToList();
                                    TopContractsEntities.Field efDefFld = context.Fields.Where(defld => defld.FieldID == DefEntFld.FieldID).SingleOrDefault();
                                    if (recordcounters.Count > 0)
                                    {
                                        foreach (long? recordcounter in recordcounters)
                                        {
                                            contract.ContractFields.Add(new TopContractsEntities.ContractField()
                                            {
                                                FieldGroupID = field.FieldGroupID,
                                                FieldID = field.FieldID,
                                                CatalogFieldID = efDefFld.FieldID,
                                                FieldValue = (efDefFld.FieldType == (int)FieldTypes.ListSingle && efDefFld.FieldListItems.Count > 0 && efDefFld.UseFirstAsDefault == true ? efDefFld.FieldListItems.First().FieldListItemID.ToString() : ""),
                                                RecordCounter = (recordcounter == null ? Convert.ToInt64(RecordCounter.Default) : recordcounter)
                                            });
                                        }
                                    }
                                    //else
                                    //{
                                    //    contract.ContractFields.Add(new TopContractsEntities.ContractField()
                                    //    {
                                    //        FieldGroupID = efFld.FieldGroupID,
                                    //        FieldID = efDefFld.FieldID,
                                    //        FieldValue = (efDefFld.FieldType == (int)FieldTypes.ListSingle && efDefFld.FieldListItems.Count > 0 && efDefFld.UseFirstAsDefault == true ? efDefFld.FieldListItems.First().FieldListItemID.ToString() : ""),
                                    //        RecordCounter = Convert.ToInt64(RecordCounter.Default)
                                    //    });
                                    //}
                                }
                            }
                        }
                    }

                    foreach (long fieldGroupId in context.Fields.Where(fg => fg.LinkedEntityID == entity.ID).Select(u => u.FieldGroupID))
                    {
                        foreach (TopContractsEntities.Contract contract in context.Contracts.Where(c => c.ContractType.ParentContractTypeID == ContractTypeContractsID))
                        {
                            foreach (TopContractsEntities.ContractField cFld in contract.ContractFields.Where(cf => cf.FieldGroupID == fieldGroupId).ToList())
                            {
                                if (entity.DefaultEntityFields.Any(f => f.FieldID == cFld.FieldID) == false)
                                {
                                    if (context.Fields.Any(f => f.FieldID == cFld.FieldID))
                                    {
                                        TopContractsEntities.FieldGroup fieldgroup = context.Fields.SingleOrDefault(f => f.FieldID == cFld.FieldID).FieldGroup;

                                        if (entityFieldGroup != null)
                                            if (entityFieldGroup.ContractTypeVisibility == (byte)FieldGroupContractTypeVisibility.VisibleToTypes && entityFieldGroup.FieldGroupsContractTypesMAPs.ToList().Count == 1)
                                            {
                                                if (entityFieldGroup.FieldGroupsContractTypesMAPs.First().ContractType.ParentContractTypeID != ContractTypeContractsID && entityFieldGroup.FieldGroupsContractTypesMAPs.First().ContractTypeID != ContractTypeContractsID)
                                                {
                                                    if (entityFieldGroup.FieldGroupID == fieldgroup.FieldGroupID)
                                                        context.ContractFields.Remove(cFld);
                                                }
                                            }
                                        //if (entities.Cast<TopContractsDAL10.SystemTables.ContractType>().Any(ent => ent.ID == fieldgroup.FieldGroupID))
                                        //{
                                        //    context.ContractFields.Remove(cFld);
                                        //}
                                    }
                                }
                            }
                        }
                    }
                }
            }
            context.SaveChanges();
        }
        public int SaveEntities(ContractTypes Data)
        {
            TopContractsV01Entities context = new TopContractsV01Entities(Utilities.getTestEnvName());
            TopContractsEntities.ContractType efContractType = null;
            foreach (TopContractsDAL10.SystemTables.ContractType contractType in Data.Entries)
            {
                if (contractType.New)
                {
                    efContractType = new TopContractsEntities.ContractType();
                }
                else
                {
                    efContractType = context.ContractTypes.Where(c => c.ContractTypeID == contractType.ID).SingleOrDefault();
                    if (contractType.Deleted == false)
                    {
                        SaveDefaultEntityFields(contractType.DefaultEntityFields.ToList(), contractType.ID);
                        SaveEntityGroup(efContractType, contractType.EntryTexts, false);
                    }
                }

                if (contractType.Deleted == false)
                {
                    efContractType.InitCommonFields(efContractType, contractType, efContractType.ContractTypesLNGs, this.organizationIdentifier);
                    //                    efContractType.SelectorFieldID = (contractType.SelectorField == (long)DefaultValues.SingleRecordID ? null : contractType.SelectorField); // To be used in case of entities
                    //Boaz 26-02-2013
                    efContractType.SelectorFieldID = (contractType.SelectorField == (long)DefaultValues.SingleRecordID || contractType.SelectorField == 0 ? null : contractType.SelectorField); // To be used in case of entities
                }

                if (contractType.New)
                {
                    context.ContractTypes.Add(efContractType);
                    context.SaveChanges(); // Saved the new contract type so that contract type id must be created and used.
                    SaveEntityGroup(efContractType, contractType.EntryTexts, true); // to create a new field group and to map it with current contract type.
                }
                else
                {
                    if (contractType.Deleted && efContractType != null)
                    {
                        // Need to be discussed with Boaz, whether the catalog type fields will be removed or LinkedEntityField will be removed.
                        foreach (TopContractsEntities.Field efFld in context.Fields.Where(fld => fld.LinkedEntityID == contractType.ID).ToList())
                        {
                            efFld.DeleteLanguageEntries(efFld, context.FieldsLNGs, efFld.FieldsLNGs);
                            context.Fields.Remove(efFld);
                        }

                        //Deleted entity records,entity fields,entity,FieldGroupsContractTypesMAPs,and Contract type --Added by deepak dhamija (28/02/2013)
                        efContractType.DeleteLanguageEntries(efContractType, context.ContractTypesLNGs, efContractType.ContractTypesLNGs);
                        FieldGroupsContractTypesMAP cTypeMap = context.FieldGroupsContractTypesMAPs.SingleOrDefault(map => map.ContractTypeID == efContractType.ContractTypeID);
                        if (cTypeMap != null)
                        {
                            //******************Condition Implemented for delete entry from FieldGroupsRolesMAP by Viplav on 15-Oct-2013********//
                            if (context.FieldGroupsRolesMAPs.Any(ent => ent.FieldGroupID == cTypeMap.FieldGroupID))
                            {
                                List<FieldGroupsRolesMAP> FieldGroupsRoleMap = context.FieldGroupsRolesMAPs.Where(t => t.FieldGroupID == cTypeMap.FieldGroupID).ToList();
                                foreach (FieldGroupsRolesMAP item in FieldGroupsRoleMap)
                                    context.FieldGroupsRolesMAPs.Remove(item);
                            }
                            //********************************************************************************************************************
                            TopContractsEntities.FieldGroup entityGroup = context.FieldGroups.SingleOrDefault(eg => eg.FieldGroupID == cTypeMap.FieldGroupID);
                            if (entityGroup != null)
                            {
                                List<TopContractsEntities.Field> entityfield = context.Fields.Where(ef => ef.FieldGroupID == cTypeMap.FieldGroupID).ToList();
                                if (entityfield != null)
                                {
                                    foreach (var flds in entityfield)
                                    {
                                        flds.DeleteLanguageEntries(flds, context.FieldsLNGs, flds.FieldsLNGs);
                                        if (flds.FieldType == (byte)FieldTypes.ListSingle)
                                        {
                                            foreach (TopContractsEntities.FieldListItem fldListItem in context.FieldListItems.Where(lstItem => lstItem.FieldID == flds.FieldID))
                                            {
                                                fldListItem.DeleteLanguageEntries(fldListItem, context.FieldListItemsLNGs, fldListItem.FieldListItemsLNGs);
                                                context.FieldListItems.Remove(fldListItem);
                                            }
                                        }

                                        foreach (TopContractsEntities.ContractField ctFld in context.ContractFields.Where(f => f.CatalogFieldID == flds.FieldID).ToList())
                                        {
                                            context.ContractFields.Remove(ctFld);
                                        }
                                        context.Fields.Remove(flds);
                                    }
                                }
                                entityGroup.DeleteLanguageEntries(entityGroup, context.FieldGroupsLNGs, entityGroup.FieldGroupsLNGs);
                                context.FieldGroups.Remove(entityGroup);
                            }
                            context.FieldGroupsContractTypesMAPs.Remove(cTypeMap);
                        }
                        context.ContractTypes.Remove(efContractType);
                        //end code--deepak dhamija
                        //Commented by deepak dhamija because its not deleted the entity records and its not verify the LinkedEntityID Exist or not.  
                        //efContractType.DeleteLanguageEntries(efContractType, context.ContractTypesLNGs, efContractType.ContractTypesLNGs);
                        //FieldGroupsContractTypesMAP cTypeMap = context.FieldGroupsContractTypesMAPs.SingleOrDefault(map => map.ContractTypeID == efContractType.ContractTypeID);
                        //if (cTypeMap != null)
                        //{
                        //    TopContractsEntities.FieldGroup entityGroup = context.FieldGroups.SingleOrDefault(eg => eg.FieldGroupID == cTypeMap.FieldGroupID);
                        //    if (entityGroup != null)
                        //    {
                        //        entityGroup.DeleteLanguageEntries(entityGroup, context.FieldGroupsLNGs, entityGroup.FieldGroupsLNGs);
                        //        context.FieldGroups.Remove(entityGroup);
                        //    }
                        //    context.FieldGroupsContractTypesMAPs.Remove(cTypeMap);
                        //}
                        //context.ContractTypes.Remove(efContractType);


                        if (context.ContractTypesFieldsToCreateDefaults.Any(ct => ct.ContractTypeID == contractType.ID))
                        {
                            foreach (TopContractsEntities.ContractTypesFieldsToCreateDefault defEntFld in context.ContractTypesFieldsToCreateDefaults.Where(ct => ct.ContractTypeID == contractType.ID).ToList())
                            {
                                context.ContractTypesFieldsToCreateDefaults.Remove(defEntFld);
                            }
                        }
                    }
                }
            }
            return context.SaveChanges();
        }
        public int Save(ContractTypes Data)
        {
            TopContractsV01Entities context = new TopContractsV01Entities(Utilities.getTestEnvName());
            TopContractsEntities.ContractType efContractType = null;
            foreach (TopContractsDAL10.SystemTables.ContractType contractType in Data.Entries)
            {
                if (contractType.New)
                {
                    efContractType = new TopContractsEntities.ContractType();
                    //efContractType.ParentContractTypeID = ConfigurationProvider.Default.ContractTypeContracts.ContractTypeContractsID;  //This parent value is used to save ContractParentID in database to make every new ContractType as Contracts
                    efContractType.ParentContractTypeID = Utilities.contractTypeContractsID;  // Code implemented by Viplav on 17 june 2013 for remove webconfig concept.
                }
                else
                {
                    efContractType = context.ContractTypes.Where(c => c.ContractTypeID == contractType.ID).SingleOrDefault();
                }

                if (contractType.Deleted == false)
                {
                    efContractType.InitCommonFields(efContractType, contractType, efContractType.ContractTypesLNGs, this.organizationIdentifier);
                    //efContractType.SelectorFieldID = contractType.SelectorField; // To be used in case of entities
                }

                if (contractType.New)
                    context.ContractTypes.Add(efContractType);
                else
                {
                    if (contractType.Deleted && efContractType != null)
                    {
                        efContractType.DeleteLanguageEntries(efContractType, context.ContractTypesLNGs, efContractType.ContractTypesLNGs);
                        context.ContractTypes.Remove(efContractType);
                    }
                }
            }
            return context.SaveChanges();
        }
Example #22
0
 public Support(string naam, Geslachten geslacht, DateTime geboorteDatum, string rijksRegisterNummer, string iban, DateTime datumInDienstTreding, double brutoLoon = 2050, ContractTypes typeContract = ContractTypes.Voltijds) : base(naam, geslacht, geboorteDatum, rijksRegisterNummer, iban, datumInDienstTreding, brutoLoon, typeContract)
 {
     ExtraLegaleVoordelen = 50;
 }
Example #23
0
 public List <ContractType> GetContractTypes()
 {
     return(ContractTypes.Where(a => a.IsDeleted == false).ToList());
 }
 private decimal CalculateSalary(ContractTypes contractType, decimal SalaryValue)
 {
     Factory.ContractType contract = FactoryCreator.Creator(contractType);
     return(contract.GetAnnualSalary(SalaryValue));
 }
        public async Task <AuthorizationAPIResult> CreateTokenAsync(
            string tokenName,
            string domainName,
            string description,
            sbyte precision,
            decimal supply,
            bool isFinalSupply,
            string owner,               // shop name
            string address,             // shop URL
            string currency,            // USD
            ContractTypes contractType, // reward or discount or custom
            Dictionary <string, string> tags)
        {
            if (string.IsNullOrWhiteSpace(domainName))
            {
                domainName = "Custom";
            }

            string ticker = domainName + "/" + tokenName;

            var blockresult = await _node.GetLastServiceBlockAsync();

            if (blockresult.ResultCode != APIResultCodes.Success)
            {
                return new AuthorizationAPIResult()
                       {
                           ResultCode = blockresult.ResultCode
                       }
            }
            ;

            ServiceBlock lastServiceBlock = blockresult.GetBlock() as ServiceBlock;

            TransactionBlock latestBlock = await GetLatestBlockAsync();

            if (latestBlock == null || latestBlock.Balances[LyraGlobal.OFFICIALTICKERCODE] < lastServiceBlock.TokenGenerationFee.ToBalanceLong())
            {
                //throw new Exception("Insufficent funds");
                return(new AuthorizationAPIResult()
                {
                    ResultCode = APIResultCodes.InsufficientFunds
                });
            }

            var svcBlockResult = await _node.GetLastServiceBlockAsync();

            if (svcBlockResult.ResultCode != APIResultCodes.Success)
            {
                throw new Exception("Unable to get latest service block.");
            }

            // initiate test coins
            TokenGenesisBlock tokenBlock = new TokenGenesisBlock
            {
                Ticker        = ticker,
                DomainName    = domainName,
                Description   = description,
                Precision     = precision,
                IsFinalSupply = isFinalSupply,
                //CustomFee = 0,
                //CustomFeeAccountId = string.Empty,
                AccountID    = AccountId,
                Balances     = new Dictionary <string, long>(),
                ServiceHash  = svcBlockResult.GetBlock().Hash,
                Fee          = lastServiceBlock.TokenGenerationFee,
                FeeCode      = LyraGlobal.OFFICIALTICKERCODE,
                FeeType      = AuthorizationFeeTypes.Regular,
                Owner        = owner,
                Address      = address,
                Currency     = currency,
                Tags         = tags,
                RenewalDate  = DateTime.UtcNow.Add(TimeSpan.FromDays(3650)),
                ContractType = contractType,
                VoteFor      = latestBlock.VoteFor
            };
            // TO DO - set service hash

            //var transaction = new TransactionInfo() { TokenCode = ticker, Amount = supply * (long)Math.Pow(10, precision) };
            var transaction = new TransactionInfo()
            {
                TokenCode = ticker, Amount = supply
            };

            tokenBlock.Balances.Add(transaction.TokenCode, transaction.Amount.ToBalanceLong()); // This is current supply in atomic units (1,000,000.00)
            tokenBlock.Balances.Add(LyraGlobal.OFFICIALTICKERCODE, latestBlock.Balances[LyraGlobal.OFFICIALTICKERCODE] - lastServiceBlock.TokenGenerationFee.ToBalanceLong());
            //tokenBlock.Transaction = transaction;
            // transfer unchanged token balances from the previous block
            foreach (var balance in latestBlock.Balances)
            {
                if (!(tokenBlock.Balances.ContainsKey(balance.Key)))
                {
                    tokenBlock.Balances.Add(balance.Key, balance.Value);
                }
            }

            await tokenBlock.InitializeBlockAsync(latestBlock, _signer);

            //tokenBlock.Signature = Signatures.GetSignature(PrivateKey, tokenBlock.Hash);

            var result = await _trans.CreateTokenAsync(tokenBlock);

            if (result.ResultCode == APIResultCodes.Success)
            {
                LastBlock = tokenBlock;
            }
            else
            {
                LastBlock = null;
            }

            return(result);
        }
        public bool Load()
        {
            PerfomanceLogger PFL = new PerfomanceLogger(SessionLog, "Contract.Load");
              if (IsValid)
              {
            /*QueryResult Data = OraQuery.Execute(Connection,
              @"select ClientID, ContractNumber, Name, ContractComment, DateStart, DateFinish, Type, State, CurrencyID, OwnerID,
               opsOnlineRestrictions.CheckContract(:ContractID, :TerminalID, :ServicePointID, :RegionID, :NetworkID, :NetworkOwnerID, Type, ClientID, OwnerID) ContractRestriction,
               opsOnlineRestrictions.CheckContractOwner(OwnerID, :TerminalID, :ServicePointID, :RegionID, :NetworkID, :NetworkOwnerID, :ContractID, Type, ClientID) ContractOwnerRestriction,
               opsOnlineRestrictions.CheckNetworkOwner(:NetworkOwnerID, :TerminalID, :ServicePointID, :RegionID, :NetworkID, :ContractID, Type, ClientID, OwnerID) NetworkOwnerRestriction,
               (select count(1) from ContractLimits z where z.ContractID = c.id) LimitsCount
             * --,
              -- (select count(1) from ContractAccounts z where z.ContractID = c.id) AccountsCount,
             --  (select count(1) from OwnerAccounts z where z.OwnerID = c.OwnerID) OwnerAccountsCount
              from Contracts c where c.id = :ContractID",
              new string[] { "ContractID", "TerminalID", "ServicePointID", "RegionID", "NetworkID", "NetworkOwnerID" },
              new object[] { ID, Terminal.ID, Terminal.ServicePoint.ID, Terminal.ServicePoint.Region.ID, Terminal.ServicePoint.Network.ID, Terminal.ServicePoint.Network.GlobalOwner.ID }, 1);*/

            if (DataObject != null)
            {
              Number = Cvt.ToString(DataObject["ContractNumber"]);
              /*Name = Cvt.ToString(Data[0, "Name"]);
              Comment = Cvt.ToString(Data[0, "ContractComment"]);*/
              DateStart = Cvt.ToDateTime(DataObject["DateStart"], DateTime.MinValue);
              DateFinish = Cvt.ToDateTime(DataObject["DateFinish"], DateTime.MinValue);
              Type = (ContractTypes)Cvt.ToByte(DataObject["Type"]);
              State = (ContractStates)Cvt.ToByte(DataObject["State"]);
              Restriction = (Restrictions)Cvt.ToByte(DataObject["ContractRestriction"]);
              ContractOwnerRestriction = (Restrictions)Cvt.ToByte(DataObject["ContractOwnerRestriction"]);
              NetworkOwnerRestriction = (Restrictions)Cvt.ToByte(DataObject["NetworkOwnerRestriction"]);
              CurrencyID = Cvt.ToUInt32(DataObject["CurrencyID"]);
              OwnerID = Cvt.ToUInt32(DataObject["OwnerID"]);
              HasTariffs = Cvt.ToInt32(DataObject["TariffsCount"]) > 0;
              HasLimits = Cvt.ToInt32(DataObject["LimitsCount"]) > 0;
              HasAccounts = Cvt.ToInt32(DataObject["AccountsCount"]) > 0;
              HasOwnerAccounts = Cvt.ToInt32(DataObject["OwnerAccountsCount"]) > 0;

              // получаем данные по клиенту, привязанному к договору
              ClientID = Cvt.ToUInt64(DataObject["ClientID"]); // контракт ВСЕГДА привязан к клиенту. Если это не так - генерируем ошибку
              /*switch (Type)
              {
            case ContractTypes.Loyalty:
              LoyaltyClient = new LoyaltyClientInfo(this);
              LoyaltyClient.ID = ClientID;
              LoyaltyClient.Load(); // получаем из БД информацию по клиенту лояльности
              break;
            case ContractTypes.Corporate:
              CorporateClient = new CorporateClientInfo(this);
              CorporateClient.ID = ClientID;
              CorporateClient.Load(); // получаем из БД информацию по корпоративному клиенту
              break;
            default:
              ErrorMessage.Add("Неизвестный тип '{0}' клиентского договора ID='{1}'", Type, ID);
              break;
              }*/

              if (ErrorMessage.IsEmpty)
              {
            /*Accounts = new ContractAccountsInfo(this);  счета загружаются по требованию
            Accounts.Load(); // загружаем счета договора*/

            /*TariffPeriods = new ContractTariffPeriodsInfo(this); активные периоды тарифов загружаются по требованию
            TariffPeriods.Load(); // загружаем действующие периоды тарифов            */

            //OwnerAccounts.Load(); // загружаем счета владельца договора
              }

              /*if (ErrorMessage.IsEmpty && Accounts.Count == 0) /*наличие счетов не проверяем...
            ErrorMessage.Add("Отсутствуют активные счета у договора {0}-{1}", Number, Name);*/
              // PA:07.08.2014 счета договора не проверяем после ввода ICardScript.DataScope

              if (ErrorMessage.IsEmpty && !Card.Transaction.Script.AvoidChecks && Card.Transaction.Source != TransactionSources.Offline)
              {
            if (ErrorMessage.IsEmpty && ContractOwnerRestriction == Restrictions.Forbidden)
              ErrorMessage.Add("Владелец договора\nзапретил обслуживание на\nданной точке продаж.");
            if (ErrorMessage.IsEmpty && NetworkOwnerRestriction == Restrictions.Forbidden)
              ErrorMessage.Add("Владелец сети ТО\nзапретил обслуживание\nдоговора на данной\nточке продаж.");

            if (ErrorMessage.IsEmpty && State != ContractStates.Allowed)
              ErrorMessage.Add("Обслуживание договора\nзапрещено");

            if (ErrorMessage.IsEmpty && Card.Transaction.TerminalDateTime < DateStart)
              ErrorMessage.Add("Договор не начал\nдействовать. Дата начала\nдействия договора:\n{0}\nТекущая дата:\n{1}", DateStart.ToString("dd.MM.yyyy HH:mm:ss"), Card.Transaction.TerminalDateTime.ToString("dd.MM.yyyy HH:mm:ss"));

            if (ErrorMessage.IsEmpty && Card.Transaction.TerminalDateTime > DateFinish)
              ErrorMessage.Add("Срок действия договора\nистёк. Дата окончания\nдействия договора:\n{0}.\nТекущая дата:\n{1}", DateFinish.ToString("dd.MM.yyyy HH:mm:ss"), Card.Transaction.TerminalDateTime.ToString("dd.MM.yyyy HH:mm:ss"));
              }
            }
            else
              ErrorMessage.Add("Договор ID = {0} не найден");
              }
              PFL.Stop();
              return ErrorMessage.IsEmpty;
        }
Example #27
0
        // [TestCaseSource(typeof(ContractTypeSearchData), "TestCases")]
        public void ContractTypeController_Get_Returns_OKResponseCode()
        {
            #region Arrange

            SetupUserIdentity();

            //string assumedOrceded = "assumed";

            //Create mock repository
            var contractTypeRepository = new Mock <IContractTypesLookupRepository>();

            //Build response
            IList <Data.Models.grs_VGrsContractType> contractTypeDbData = new List <Data.Models.grs_VGrsContractType>
            {
                new Data.Models.grs_VGrsContractType
                {
                    Code          = 11,
                    Exposurename  = "Reinsurance - Treaty",
                    InsuranceName = "test",
                    AssumedFlag   = 1,
                    AssumedName   = "Treaty",
                    CededFlag     = null,
                    Exposuretype  = 1,
                    Active        = true,
                    Catorder      = 1,
                    CededName     = "ceded",
                    RowId         = 1
                },
            };
            #endregion
            // Search method

            contractTypeRepository.Setup(p => p.GetContractTypes())
            .Returns(contractTypeDbData);

            //Manager
            //ContractTypesManager contractTypeManager = new ContractTypesManager(userManager.Object, cacheStoreManager.Object, mockLogManager.Object, contractTypeRepository.Object, transformationManager, new Mock<IPersonProfileManager>().Object);
            ContractTypesManager contractTypeManager = new ContractTypesManager(userManager.Object, cacheStoreManager.Object, mockLogManager.Object, contractTypeRepository.Object, transformationManager);

            var httpRequest = new HttpRequestMessage(new HttpMethod(AppSettings.HTTPGET), $"{AppSettings.BASEURL}{RouteHelper.LookupsContractTypesRoutePrefix}");

            DealAPIManager dealAPIManager = new DealAPIManager(userManager.Object, cacheStoreManager.Object, mockLogManager.Object, new Mock <IDealManager>().Object, new Mock <IEntityLockManager>().Object);


            ContractTypesLookupController contractTypeController = new ContractTypesLookupController(userManager.Object, dealAPIManager)
            {
                Request       = httpRequest,
                Configuration = new HttpConfiguration()
            };



            #region Act

            //var response = contractTypeController.Get(criteria);

            // CoverageBasisSearchCriteria dsc = new CoverageBasisSearchCriteria { assumedOrCededFlag = "assumed" };
            var response = contractTypeController.Get();

            //var response = contractTypeController.Get(It.IsAny<DealNotesSearchCriteria>());
            var contentResult = response as NegotiatedContentResult <ResponseCollection <ContractTypes> >;

            #endregion

            #region Assert



            var expectedContractType = new ContractTypes
            {
                name     = "Treaty",
                value    = "11",
                group    = "1",
                isActive = true
            };


            if (contentResult != null)
            {
                Assertions.AssertOkResponse(contentResult);

                var contractTypeData = contentResult.Content.results;

                for (int i = 0; i <= contractTypeData.Count - 1; i++)
                {
                    var actualcontractTypes = contractTypeData[i].data;

                    Assertions.AssertData(expectedContractType, actualcontractTypes);
                    Assert.IsEmpty(contractTypeData[i].messages);
                }
            }

            #endregion
        }
 public Programmeur(string naam, Geslachten geslacht, DateTime geboorteDatum, string rijksRegisterNummer, string iban, DateTime datumInDienstTreding, bool bedrijfsWagen = false, double brutoLoon = 2200, ContractTypes typeContract = ContractTypes.Voltijds) : base(naam, geslacht, geboorteDatum, rijksRegisterNummer, iban, datumInDienstTreding, brutoLoon, typeContract)
 {
     BedrijfsWagen       = bedrijfsWagen;
     BedrijfsVoorheffing = (bedrijfsWagen ? 17.30 : 13.68);
     FunctieTitel        = "Programmeur";
 }