Пример #1
0
        public string Update(CodeCombinition entity)
        {
            var originalEntity = this.Context.CodeCombinitions.Find(entity.Id);

            entity.CreateBy   = originalEntity.CreateBy;
            entity.CreateDate = originalEntity.CreateDate;
            this.Context.Entry(originalEntity).CurrentValues.SetValues(entity);
            this.Context.Entry(originalEntity).State = EntityState.Modified;
            this.Commit();
            return(entity.Id.ToString());
        }
Пример #2
0
 public CodeCombinitionCreateViewModel(CodeCombinition entity)
 {
     this.AllowedPosting = entity.AllowedPosting;
     this.CompanyId      = entity.CompanyId;
     this.EndDate        = entity.EndDate;
     this.Id             = entity.Id;
     this.Segment1       = entity.Segment1;
     this.Segment2       = entity.Segment2;
     this.Segment3       = entity.Segment3;
     this.Segment4       = entity.Segment4;
     this.Segment5       = entity.Segment5;
     this.Segment6       = entity.Segment6;
     this.Segment7       = entity.Segment7;
     this.Segment8       = entity.Segment8;
 }
Пример #3
0
        private CodeCombinitionView GetCodeCombViewByCodeCombEntity(CodeCombinition entity)
        {
            if (entity == null)
            {
                return(null);
            }

            CodeCombinitionView obj = new CodeCombinitionView();

            obj.AllowedPosting      = entity.AllowedPosting;
            obj.CodeCombinitionCode = Utility.CodeCombination(entity, ".");
            obj.CompanyId           = entity.CompanyId;
            obj.EndDate             = entity.EndDate;
            obj.Id        = entity.Id;
            obj.SOBId     = entity.SOBId;
            obj.StartDate = entity.StartDate;
            return(obj);
        }
        private static CodeCombinition getEntityByModel(CodeCombinitionCreateViewModel model)
        {
            if (model == null)
            {
                return(null);
            }

            var entity = new CodeCombinition();

            entity.AllowedPosting = model.AllowedPosting;
            entity.EndDate        = model.EndDate;
            entity.Id             = model.Id;
            entity.Segment1       = model.Segment1;
            entity.Segment2       = model.Segment2;
            entity.Segment3       = model.Segment3;
            entity.Segment4       = model.Segment4;
            entity.Segment5       = model.Segment5;
            entity.Segment6       = model.Segment6;
            entity.Segment7       = model.Segment7;
            entity.Segment8       = model.Segment8;
            entity.SOBId          = model.SOBId;
            entity.StartDate      = model.StartDate;

            if (model.Id == 0)
            {
                entity.CompanyId  = AuthenticationHelper.CompanyId.Value;
                entity.CreateBy   = AuthenticationHelper.UserId;
                entity.CreateDate = DateTime.Now;
            }
            else
            {
                entity.CompanyId  = model.CompanyId;
                entity.CreateBy   = model.CreateBy;
                entity.CreateDate = model.CreateDate;
            }
            entity.UpdateBy   = AuthenticationHelper.UserId;
            entity.UpdateDate = DateTime.Now;

            return(entity);
        }
 public CodeCombinitionCreateViewModel(CodeCombinition entity)
 {
     if (entity != null)
     {
         this.AllowedPosting = entity.AllowedPosting;
         this.CompanyId      = entity.CompanyId;
         this.StartDate      = entity.StartDate;
         this.EndDate        = entity.EndDate;
         this.Id             = entity.Id;
         this.Segment1       = entity.Segment1;
         this.Segment2       = entity.Segment2;
         this.Segment3       = entity.Segment3;
         this.Segment4       = entity.Segment4;
         this.Segment5       = entity.Segment5;
         this.Segment6       = entity.Segment6;
         this.Segment7       = entity.Segment7;
         this.Segment8       = entity.Segment8;
         this.CreateBy       = entity.CreateBy;
         this.CreateDate     = entity.CreateDate;
         this.UpdateBy       = entity.UpdateBy;
         this.UpdateDate     = entity.UpdateDate;
     }
 }
Пример #6
0
 public string Update(CodeCombinition entity)
 {
     return(this.repository.Update(entity));
 }
Пример #7
0
 public string Insert(CodeCombinition entity)
 {
     return(this.repository.Insert(entity));
 }
Пример #8
0
        public long GetAccountIdBySegments(string segments, long companyId, long sobId)
        {
            var segmentList = segments.Split(new char[] { '.' }, StringSplitOptions.None);
            var query       = this.Context.CodeCombinitions.Where(x => x.CompanyId == companyId && x.SOBId == sobId && x.AllowedPosting == true);

            for (int i = 0; i < segmentList.Count(); i++)
            {
                switch (i)
                {
                case 0:
                    string segment1 = segmentList[i];
                    query = query.Where(x => x.Segment1 == segment1);
                    break;

                case 1:
                    string segment2 = segmentList[i];
                    query = query.Where(x => x.Segment2 == segment2);
                    break;

                case 2:
                    string segment3 = segmentList[i];
                    query = query.Where(x => x.Segment3 == segment3);
                    break;

                case 3:
                    string segment4 = segmentList[i];
                    query = query.Where(x => x.Segment4 == segment4);
                    break;

                case 4:
                    string segment5 = segmentList[i];
                    query = query.Where(x => x.Segment5 == segment5);
                    break;

                case 5:
                    string segment6 = segmentList[i];
                    query = query.Where(x => x.Segment6 == segment6);
                    break;

                case 6:
                    string segment7 = segmentList[i];
                    query = query.Where(x => x.Segment7 == segment7);
                    break;

                case 7:
                    string segment8 = segmentList[i];
                    query = query.Where(x => x.Segment8 == segment8);
                    break;
                }
            }
            CodeCombinition entity = query.FirstOrDefault();

            if (entity != null)
            {
                return(entity.Id);
            }
            else
            {
                return(0);
            }
        }
Пример #9
0
 public string Insert(CodeCombinition entity)
 {
     this.Context.CodeCombinitions.Add(entity);
     this.Commit();
     return(entity.Id.ToString());
 }
Пример #10
0
        public CodeCombinition GetSingle(string id, long companyId)
        {
            CodeCombinition codeCombinition = this.GetAll(companyId).FirstOrDefault(x => x.Id == Convert.ToInt32(id));

            return(codeCombinition);
        }
Пример #11
0
 public static string CodeCombination(CodeCombinition entity, string delimeter)
 {
     return
         (Stringize(delimeter, entity.Segment1, entity.Segment2, entity.Segment3, entity.Segment4, entity.Segment5, entity.Segment6, entity.Segment7, entity.Segment8));
 }