Exemplo n.º 1
0
        public JsonResult InsertInvestment(int caseId, int caseDetailId, DateTime?fechadecision, string payments, string comment, string caseNumber, int beneficiario)
        {
            DateTime workingDate = DateTime.Now;

            var currentCase = CaseService.FindCaseByNumber(caseNumber);

            var transaction = new Transaction
            {
                CaseDetailId      = caseDetailId,
                TransactionTypeId = (int)TransactionTypeEnum.Inversion,
                TransactionDate   = workingDate,
                TransactionAmount = decimal.Zero,
                Comment           = comment
            };

            TransactionService.CreateTransaction(transaction);


            var amount = decimal.Zero;

            var serializedPayments = JsonConvert.DeserializeObject <List <PaymentTransaction> >(payments);

            foreach (var serializedPayment in serializedPayments)
            {
                var entidad = new Entity
                {
                    FullName = serializedPayment.Entidad,
                    SourceId = 9
                };
                EntityService.CreateEntity(entidad);

                var payment = new Payment
                {
                    CaseId           = caseId,
                    CaseDetailId     = caseDetailId,
                    TransactionId    = transaction.TransactionId,
                    CaseNumber       = caseNumber,
                    ConceptId        = currentCase.ConceptId.Value,
                    ClassId          = 3,
                    Amount           = serializedPayment.Inversion,
                    EntityId_RemitTo = entidad.EntityId,
                    Remitter         = entidad,
                    ToDate           = fechadecision,
                    TransactionNum   = transaction.TransactionId.ToString().PadLeft(9, '0'),
                    CheckBk          = 0,
                    StatusId         = 12,
                    IssueDate        = workingDate,
                    StatusChangeDate = workingDate
                };
                amount += serializedPayment.Inversion.Value;

                PaymentService.CreatePayment(payment);
            }

            transaction.TransactionAmount = amount;

            TransactionService.ModifyTransaction(transaction);

            return(Json(new BasicDataTablesResult(new { Status = "OK" })));
        }
Exemplo n.º 2
0
 public JsonResult Post(string name)
 {
     if (string.IsNullOrWhiteSpace(name))
     {
         return(new JsonResult("实体名称不能为空"));
     }
     entityService.CreateEntity(name, System.IO.Path.Combine(hostingEnvironment.ContentRootPath, "Models"));
     return(new JsonResult("生成成功"));
 }
        public JsonResult CreateEntity(string entityName = null)
        {
            IEntity IEntity = new EntityService();

            if (entityName == null)
            {
                return(Json("参数为空"));
            }
            string filePath = Directory.GetCurrentDirectory();

            filePath = filePath.Substring(0, filePath.LastIndexOf('\\')) + "\\" + "Core.Entity";
            return(Json(IEntity.CreateEntity(entityName, filePath)));
        }
Exemplo n.º 4
0
        /// <summary>
        /// 生成实体类
        /// </summary>
        /// <param name="entityName"></param>
        /// <param name="filePath"></param>
        /// <returns></returns>
        public BizResult <string> CreateEntity(string entityName, string contentRootPath)
        {
            try
            {
                string[] arr = contentRootPath.Split('\\');
                string   baseFileProvider = "";
                for (int i = 0; i < arr.Length - 1; i++)
                {
                    baseFileProvider += arr[i];
                    baseFileProvider += "\\";
                }
                string filePath = baseFileProvider + "NexChip.SignMessage.Entities";
                try
                {
                    if (iService.CreateEntity(entityName, filePath))
                    {
                        return new BizResult <string> {
                                   Success = true, Msg = "生成成功"
                        }
                    }
                    ;
                    else
                    {
                        return new BizResult <string> {
                                   Success = false, Msg = "生成失败"
                        }
                    };


                    //var s = Db.Ado.GetDataTable("select * from Student");
                    //var s2 = Db.Queryable<Student>().ToSql();
                    //Db.DbFirst.IsCreateAttribute().Where(entityName).CreateClassFile(filePath);
                    //return new BizResult<string> { Success = true, Msg = "生成成功" };
                }
                catch (Exception ex)
                {
                    return(new BizResult <string> {
                        Success = false, Msg = ex.Message
                    });
                }

                //db.DbFirst.IsCreateAttribute().Where(entityName).CreateClassFile(filePath);
                //return true;
            }
            catch (Exception)
            {
                return(new BizResult <string> {
                    Success = false
                });
            }
        }
Exemplo n.º 5
0
 public void EntityCreateTest()
 {
     try
     {
         var NewEntityId = EntityService.CreateEntity(new ConfigModel {
             AccesTokenDeveloper = DeveloperAccessToken
         }, "test_entity_1", new Dictionary <string, string[]> {
             { "test1", new[] { "test 1", "test one" } },
             { "test2", new[] { "test 2", "test second" } }
         });
     }
     catch (ApiAiException ex)
     {
         // Use debug to check this "ex" value
         Assert.Fail();
     }
 }
Exemplo n.º 6
0
        public JsonResult UpdateInvestments(UpdateInvestmentRequest model)
        {
            var transaction = TransactionService.FindTransactionById(model.TransactionId);
            var workingDate = DateTime.Now;
            var amount      = decimal.Zero;

            var modelPayments = ConvertToPaymentModel(model);

            var paymentsToUpdate = BuildInvestmentPaymentSets(modelPayments, transaction.Payments);

            foreach (var newPayment in paymentsToUpdate["new"])
            {
                var newEntity = new Entity
                {
                    FullName = newPayment.Remitter.FullName,
                    SourceId = 9
                };

                EntityService.CreateEntity(newEntity);

                var payment = new Payment
                {
                    CaseId           = model.CaseId,
                    CaseDetailId     = model.CaseDetailId,
                    TransactionId    = transaction.TransactionId,
                    CaseNumber       = model.CaseNumber,
                    ConceptId        = 2,
                    ClassId          = 3,
                    Amount           = newPayment.Amount,
                    EntityId_RemitTo = newEntity.EntityId,
                    Remitter         = newEntity,
                    ToDate           = transaction.TransactionDate,
                    TransactionNum   = transaction.TransactionId.ToString().PadLeft(9, '0'),
                    CheckBk          = 0,
                    StatusId         = 2,
                    IssueDate        = workingDate,
                    StatusChangeDate = workingDate
                };

                PaymentService.CreatePayment(payment);

                amount += payment.Amount.GetValueOrDefault(decimal.Zero);
            }

            foreach (var changedPayment in paymentsToUpdate["changed"])
            {
                if (changedPayment != null && changedPayment.EntityId_RemitTo == null)
                {
                    continue;
                }
                if (changedPayment == null)
                {
                    continue;
                }
                var existingEntity = EntityService.GetById(changedPayment.EntityId_RemitTo.Value);
                var payment        = PaymentService.FindPaymentById(changedPayment.PaymentId);

                if (changedPayment.Remitter != null)
                {
                    existingEntity.FullName = changedPayment.Remitter.FullName;
                }
                EntityService.ModifyEntity(existingEntity);

                payment.Amount = payment.Amount.GetValueOrDefault(decimal.Zero);
                PaymentService.ModifyPayment(payment);

                amount += payment.Amount.Value;
            }

            foreach (var removedPayment in paymentsToUpdate["removed"])
            {
                if (removedPayment == null)
                {
                    continue;
                }
                var transactionId = removedPayment.TransactionId;
                PaymentService.Delete(removedPayment.PaymentId);
                if (removedPayment.EntityId_RemitTo != null)
                {
                    EntityService.Delete(removedPayment.EntityId_RemitTo);
                }
                if (transactionId != null)
                {
                    TransactionService.Delete(transactionId.Value);
                }
            }

            transaction.TransactionAmount = amount;
            transaction.Comment           = model.Comment;

            TransactionService.ModifyTransaction(transaction);

            return(Json(new BasicDataTablesResult(new { Status = "OK" })));
        }
Exemplo n.º 7
0
        //Process client side data and updates demographic data in the database.
        public JsonResult Edit(DemographicViewModel demographic)
        {
            if (demographic.CaseDetail != null)
            {
                var caseDetail = CaseService.FindCaseDetailById(demographic.CaseDetailId);
                if (caseDetail != null)
                {
                    if (caseDetail.CaseKey != "00")
                    {
                        var relationship = RelationshipTypeService.GetRelationshipTypes()
                                           .Where(x => x.RelationshipType1 == demographic.Relationship &&
                                                  x.WidowCertification == demographic.CaseDetail.Entity.HasWidowCertification)
                                           .FirstOrDefault();

                        caseDetail.RelationshipType   = relationship;
                        caseDetail.RelationshipTypeId = relationship.RelationshipTypeId;
                    }

                    #region Entity Information
                    Entity entity = new Entity();
                    if (!demographic.InsertNewEntity)
                    {
                        entity = EntityService.GetById(Convert.ToInt32(caseDetail.EntityId_Sic));
                    }

                    entity.FirstName  = demographic.CaseDetail.Entity.FirstName.Trim();
                    entity.MiddleName = demographic.CaseDetail.Entity.MiddleName != null?demographic.CaseDetail.Entity.MiddleName.Trim() : null;

                    entity.LastName       = demographic.CaseDetail.Entity.LastName.Trim();
                    entity.SecondLastName = demographic.CaseDetail.Entity.SecondLastName != null?demographic.CaseDetail.Entity.SecondLastName.Trim() : null;

                    entity.FullName = string.Concat(
                        entity.FirstName + " ",
                        entity.MiddleName.IsNullOrEmpty() ? String.Empty : entity.MiddleName + " ",
                        entity.LastName + "  ",
                        entity.SecondLastName.IsNullOrEmpty() ? String.Empty : entity.SecondLastName + " ");

                    entity.CaseNumber             = demographic.CaseDetail.CaseNumber;
                    entity.CaseKey                = demographic.CaseDetail.CaseKey;
                    entity.SSN                    = demographic.CaseDetail.Entity.SSN;
                    entity.IDNumber               = demographic.CaseDetail.Entity.IDNumber;
                    entity.BirthDate              = demographic.CaseDetail.Entity.BirthDate;
                    entity.DeceaseDate            = demographic.CaseDetail.Entity.DeceaseDate;
                    entity.MarriageDate           = demographic.CaseDetail.Entity.MarriageDate;
                    entity.CivilStatusId          = demographic.CaseDetail.Entity.CivilStatusId;
                    entity.IsStudying             = demographic.CaseDetail.Entity.IsStudying;
                    entity.SchoolStartDate        = demographic.CaseDetail.Entity.SchoolStartDate;
                    entity.SchoolEndDate          = demographic.CaseDetail.Entity.SchoolEndDate;
                    entity.HasDisability          = demographic.CaseDetail.Entity.HasDisability;
                    entity.OccupationId           = demographic.CaseDetail.Entity.OccupationId;
                    entity.MonthlyIncome          = demographic.CaseDetail.Entity.MonthlyIncome;
                    entity.IsRehabilitated        = demographic.CaseDetail.Entity.IsRehabilitated;
                    entity.IsWorking              = demographic.CaseDetail.Entity.IsWorking;
                    entity.IsEmancipated          = demographic.CaseDetail.Entity.IsEmancipated;
                    entity.HasWidowCertification  = demographic.CaseDetail.Entity.HasWidowCertification;
                    entity.WidowCertificationDate = demographic.CaseDetail.Entity.WidowCertificationDate;
                    entity.ModifiedReasonId       = demographic.CaseDetail.Entity.ModifiedReasonId;
                    entity.OtherModifiedReason    = demographic.CaseDetail.Entity.OtherModifiedReason;
                    entity.Comments               = demographic.CaseDetail.Entity.Comments;
                    entity.Email                  = demographic.CaseDetail.Entity.Email;
                    entity.HomePhoneNumber        = demographic.CaseDetail.Entity.HomePhoneNumber;
                    entity.CellPhoneNumber        = demographic.CaseDetail.Entity.CellPhoneNumber;
                    entity.WorkPhoneNumber        = demographic.CaseDetail.Entity.WorkPhoneNumber;
                    entity.FaxPhoneNumber         = demographic.CaseDetail.Entity.FaxPhoneNumber;
                    entity.OtherPhoneNumber       = demographic.CaseDetail.Entity.OtherPhoneNumber;

                    entity.ModifiedBy       = WebHelper.GetUserName();
                    entity.ModifiedDateTime = DateTime.Now;
                    #endregion

                    #region Address Information
                    if (demographic.PostalAddress != null)
                    {
                        Address PostalAddress = demographic.PostalAddress;

                        //Verificar una manera de traer toda la informaicon de coutry / state a traves de ciudad.
                        var    city  = LocationService.GetAllCities().Where(x => x.CityId == demographic.PostalAddress.CityId).FirstOrDefault();
                        string state = "";
                        if (demographic.PostalAddress.StateId != null)
                        {
                            var state1 = LocationService.GetAllStates().Where(x => x.StateId == demographic.PostalAddress.StateId).FirstOrDefault();
                            state = state1.State1;
                        }
                        var country = LocationService.GetAllCountries().Where(x => x.CountryId == demographic.PostalAddress.CountryId).FirstOrDefault();

                        PostalAddress.FullAddress =
                            demographic.PostalAddress.Line1
                            + (demographic.PostalAddress.Line2.IsNullOrEmpty() ? "" : " " + demographic.PostalAddress.Line2.Trim())
                            + (demographic.PostalAddress.CityId == null ? "" : city.City1 != "Otro" ? " " + city.City1 : " " + demographic.PostalAddress.OtherCity)
                            + (demographic.PostalAddress.StateId == null ? "" : ", " + state)
                            + (demographic.PostalAddress.CountryId == null ? "" : ", " + country.Country1)
                            + (demographic.PostalAddress.ZipCode == null ? "" : " " + demographic.PostalAddress.ZipCode)
                            + (demographic.PostalAddress.ZipCodeExt == null ? "" : "-" + demographic.PostalAddress.ZipCodeExt);
                        PostalAddress.AddressTypeId    = AddressTypeService.GetAddressTypes().Where(x => x.AddressType1 == "Postal").Select(x => x.AddressTypeId).FirstOrDefault();
                        PostalAddress.SourceId         = 8;
                        PostalAddress.ModifiedBy       = WebHelper.GetUserName();
                        PostalAddress.ModifiedDateTime = DateTime.Now;

                        if (!demographic.HasAddress)
                        {
                            PostalAddress.CreatedBy       = WebHelper.GetUserName();
                            PostalAddress.CreatedDateTime = DateTime.Now;
                            entity.Addresses.Add(PostalAddress);
                        }
                        else
                        {
                            foreach (var a in demographic.CaseDetail.Entity.Addresses)
                            {
                                if (a.AddressType.AddressType1 == "Postal" && a.AddressId == demographic.PostalAddress.AddressId)
                                {
                                    a.Line1       = demographic.PostalAddress.Line1;
                                    a.Line2       = demographic.PostalAddress.Line2;
                                    a.CityId      = demographic.PostalAddress.CityId;
                                    a.OtherCity   = demographic.PostalAddress.OtherCity;
                                    a.StateId     = demographic.PostalAddress.StateId;
                                    a.CountryId   = demographic.PostalAddress.CountryId;
                                    a.ZipCode     = demographic.PostalAddress.ZipCode;
                                    a.ZipCodeExt  = demographic.PostalAddress.ZipCodeExt;
                                    a.FullAddress = demographic.PostalAddress.FullAddress;
                                    a.EntityId    = demographic.PostalAddress.EntityId;
                                }
                            }
                        }
                    }
                    #endregion

                    //#region Phone Information

                    //#endregion

                    if (demographic.InsertNewEntity)
                    {
                        entity.SourceId        = 8; //SourceId = Entity Sic Source
                        entity.CreatedBy       = WebHelper.GetUserName();
                        entity.CreatedDateTime = DateTime.Now;
                        try
                        {
                            EntityService.CreateEntity(entity);
                        }
                        catch
                        {
                            throw new Exception();
                        }
                    }
                    else
                    {
                        try
                        {
                            EntityService.ModifyEntity(entity);
                        }
                        catch
                        {
                            throw new Exception();
                        }
                    }

                    caseDetail.Entity       = entity;
                    caseDetail.EntitySic    = entity;
                    caseDetail.EntityId     = entity.EntityId;
                    caseDetail.EntityId_Sic = entity.EntityId;

                    try
                    {
                        CaseService.UpdateCaseDetail(caseDetail);
                    }
                    catch
                    {
                        EntityService.Delete(entity.EntityId);
                        throw new Exception();
                    }

                    return(Json(new { Data = demographic.CaseDetail }));
                }
                else
                {
                    throw new Exception();
                }
            }
            else
            {
                throw new Exception();
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Creates new participant entity
        /// </summary>
        /// <param name="entity">Entity Data</param>
        /// <param name="PostalAddress">Address Data</param>
        /// <returns></returns>
        public JsonResult CreateParticipant(Entity entity, Address PostalAddress)
        {
            if (entity != null)
            {
                entity.FullName = string.Concat(
                    entity.FirstName + " ",
                    entity.MiddleName.IsNullOrEmpty() ? String.Empty : entity.MiddleName + " ",
                    entity.LastName + "  ",
                    entity.SecondLastName.IsNullOrEmpty() ? String.Empty : entity.SecondLastName + " ");

                if (PostalAddress != null)
                {
                    //Address address = new Address();
                    //address.Line1 = PostalAddress.Line1;
                    var    city  = LocationService.GetAllCities().Where(x => x.CityId == PostalAddress.CityId).FirstOrDefault();
                    string state = "";
                    if (PostalAddress.StateId != null)
                    {
                        var state1 = LocationService.GetAllStates().Where(x => x.StateId == PostalAddress.StateId).FirstOrDefault();
                        state = state1.State1;
                    }
                    var country = LocationService.GetAllCountries().Where(x => x.CountryId == PostalAddress.CountryId).FirstOrDefault();

                    PostalAddress.FullAddress =
                        PostalAddress.Line1
                        + (PostalAddress.Line2.IsNullOrEmpty() ? "" : " " + PostalAddress.Line2.Trim())
                        + (PostalAddress.CityId == null ? "" : city.City1 != "Otro" ? " " + city.City1 : " " + PostalAddress.OtherCity)
                        + (PostalAddress.StateId == null ? "" : ", " + state)
                        + (PostalAddress.CountryId == null ? "" : ", " + country.Country1)
                        + (PostalAddress.ZipCode == null ? "" : " " + PostalAddress.ZipCode)
                        + (PostalAddress.ZipCodeExt == null ? "" : "-" + PostalAddress.ZipCodeExt);
                    PostalAddress.AddressTypeId    = AddressTypeService.GetAddressTypes().Where(x => x.AddressType1 == "Postal").Select(x => x.AddressTypeId).FirstOrDefault();
                    PostalAddress.SourceId         = 8;
                    PostalAddress.CreatedBy        = WebHelper.GetUserName();
                    PostalAddress.CreatedDateTime  = DateTime.Now;
                    PostalAddress.ModifiedBy       = WebHelper.GetUserName();
                    PostalAddress.ModifiedDateTime = DateTime.Now;
                    entity.Addresses.Add(PostalAddress);
                }

                entity.SourceId         = 8;
                entity.CreatedBy        = WebHelper.GetUserName();
                entity.CreatedDateTime  = DateTime.Now;
                entity.ModifiedBy       = WebHelper.GetUserName();
                entity.ModifiedDateTime = DateTime.Now;

                try
                {
                    EntityService.CreateEntity(entity);
                    return(Json(entity));
                }
                catch
                {
                    throw new Exception();
                }
            }
            else
            {
                throw new Exception();
            }
        }
Exemplo n.º 9
0
        public JsonResult Insert(ThirdPartyPaymentModel model)
        {
            int?newEntityId = null;
            var entity      = new Entity();
            var address     = new Address();

            if (model.EntityTypeId == 1)
            {
                entity = new Entity
                {
                    SourceId       = 8,
                    FirstName      = model.CustodyFirstName,
                    MiddleName     = model.CustodySecondName,
                    LastName       = model.CustodyFirstLastName,
                    SecondLastName = model.CustodySecondLastName,
                    FullName       = string.Format("{0} {1} {2} {3}", model.CustodyFirstName, model.CustodySecondName, model.CustodyFirstLastName, model.CustodySecondLastName)
                };

                address = new Address
                {
                    EntityId    = entity.EntityId,
                    SourceId    = 8,
                    FullAddress = string.Format("{0} {1}", model.CustodyAddressLine1, model.CustodyAddressLine2),
                    Line1       = model.CustodyAddressLine1,
                    Line2       = model.CustodyAddressLine2,
                    CityId      = model.CustodyCityId,
                    ZipCode     = model.CustodyPostalCode == null ? string.Empty : model.CustodyPostalCode.Trim().Replace('-', '\0').PadRight(9, '0').Substring(0, 5),
                    ZipCodeExt  = model.CustodyPostalCode == null ? string.Empty : model.CustodyPostalCode.Trim().Replace('-', '\0').PadRight(9, '0').Substring(5, 4)
                };
                entity.Addresses.Add(address);

                EntityService.CreateEntity(entity);

                newEntityId = entity.EntityId;
            }
            else if (model.EntityTypeId == 2)
            {
                entity = new Entity
                {
                    SourceId = 9,
                    FullName = model.EntityName
                };

                address = new Address
                {
                    SourceId    = 9,
                    EntityId    = entity.EntityId,
                    FullAddress = string.Format("{0} {1}", model.EntityAddressLine1, model.EntityAddressLine2),
                    Line1       = model.EntityAddressLine1,
                    Line2       = model.EntityAddressLine2,
                    CityId      = model.EntityCityId,
                    ZipCode     = model.EntityPostalCode == null ? string.Empty : model.EntityPostalCode.Trim().Replace('-', '\0').PadRight(9, '0').Substring(0, 5),
                    ZipCodeExt  = model.EntityPostalCode == null ? string.Empty : model.EntityPostalCode.Trim().Replace('-', '\0').PadRight(9, '0').Substring(5, 4)
                };
                entity.Addresses.Add(address);

                EntityService.CreateEntity(entity);

                newEntityId = entity.EntityId;
            }
            else if (model.EntityTypeId == 3)
            {
                newEntityId = model.CourtId;
            }

            decimal amount = decimal.Zero;

            if (model.SinglePaymentAmount.HasValue)
            {
                amount = model.SinglePaymentAmount.Value;
            }
            else
            {
                amount = model.FirstInstallmentAmount.GetValueOrDefault(decimal.Zero) + model.SecondInstallmentAmount.GetValueOrDefault(decimal.Zero);
            }

            var thirdPartySchedule = new ThirdPartySchedule
            {
                CaseId                  = model.CaseId,
                CaseDetailId            = model.CaseDetailId,
                EntityId_RemitTo        = model.EntityTypeId == 2 || model.EntityTypeId == 3 ? newEntityId : null,
                ClaimNumber             = model.ClaimNumber,
                OrderIdentifier         = model.OrderIdentifier,
                TerminationFlag         = model.TerminationFlag,
                EffectiveDate           = model.EffectiveDate,
                TerminationOrderNumber  = model.TerminationOrderNumber,
                SinglePaymentAmount     = model.SinglePaymentAmount,
                FirstInstallmentAmount  = model.FirstInstallmentAmount,
                SecondInstallmentAmount = model.SecondInstallmentAmount,
                Comment                 = model.Comment,
                OrderAmount             = model.OrderAmount,
                TerminationDate         = model.TerminationDate,
                CreatedDateTime         = System.DateTime.UtcNow,
                CreatedBy               = WebHelper.GetUserName(),
            };

            PaymentService.CreateThirdPayment(thirdPartySchedule);

            return(Json(new BasicDataTablesResult(new { Status = "OK" })));
        }