コード例 #1
0
 public void InsertFeatureSetTest()
 {
     FeatureSetService service = new FeatureSetService(new FeatureSetRepository());
     FeatureSet entity = new FeatureSet();
     entity.Name = "Featureset - GL";
     entity.AccessType = FeatureAccessType.company.ToString();
     entity.CreateDate = DateTime.Now;
     var result = service.Insert(entity);
     Assert.IsTrue(Convert.ToInt64(result) > 0);
 }
コード例 #2
0
 public string Update(FeatureSet entity)
 {
     var originalEntity = this.Context.FeatureSets.Find(entity.Id);
     entity.CreateBy = originalEntity.CreateBy;
     entity.CreateDate = originalEntity.CreateDate;
     entity.AccessType = originalEntity.AccessType;
     this.Context.Entry(originalEntity).CurrentValues.SetValues(entity);
     this.Context.Entry(originalEntity).State = EntityState.Modified;
     this.Commit();
     return entity.Id.ToString();
 }
コード例 #3
0
 public void InsertCompanyFeatureSet(FeatureSet fs, FeatureSetAccess fsa)
 {
     var result = this.fsRepo.Insert(fs);
     
     long outValue = 0;
     if (long.TryParse(result, out outValue))    //faisal bhai sidha sidha convert.toint32 q nhi kia itni lambi q ki???
     {
         foreach (var f in fs.FeatureSetList)
         {
             f.FeatureSetId = outValue;
         }
         fslRepo.Insert(fs.FeatureSetList.ToList());
         fsa.FeatureSetId = outValue;
         result = this.fsaRepo.Insert(fsa);
     }
 }
コード例 #4
0
 public FeatureSetModel(FeatureSet x)
 {
     this.Id = x.Id;
     this.Name = x.Name;
     this.AccessType = x.AccessType;
 }
コード例 #5
0
        public JsonResult UpdateCompanyFeature(long companyId, string featureName, string featureList)
        {
            FeatureSet fs = new FeatureSet();
            fs.Name = featureName;
            fs.AccessType = "company";
            fs.CreateDate = DateTime.Now;
            List<FeatureSetList> fsList = new List<FeatureSetList>();
            var newValue = featureList.Replace("undefined|","").Replace("undefined±","").Split(new char[] { '±' }, StringSplitOptions.None);
            foreach(string s in newValue)
            {
                if (!string.IsNullOrEmpty(s))
                {
                    fsList.Add(new FeatureSetList { FeatureId = long.Parse(s.Split(new char[] { '|' }, StringSplitOptions.None)[0]), FeatureSetId = fs.Id });
                }
            }
            fs.FeatureSetList = fsList;

            FeatureSetAccess fsa = new FeatureSetAccess();
            fsa.CompanyId = companyId;
            fsa.FeatureSetId = fs.Id;
            fsa.CreateDate = DateTime.Now;

            service.InsertCompanyFeatureSet(fs, fsa);

            return Json("Success");
        }
コード例 #6
0
        public JsonResult UpdateCompanyFeature(long id, long companyId, string featureName, string featureList)
        {
            FeatureSet fs = new FeatureSet();
            fs.Name = featureName;
            fs.Id = id;
            fs.CompanyId = companyId;
            fs.UpdateBy = AuthenticationHelper.UserId;
            fs.UpdateDate = DateTime.Now;

            List<FeatureSetList> fsList = new List<FeatureSetList>();
            var newValue = featureList.Replace("undefined|", "").Replace("undefined±", "").Split(new char[] { '±' }, StringSplitOptions.None);
            foreach (string s in newValue)
            {
                if (!string.IsNullOrEmpty(s))
                {
                    fsList.Add(new FeatureSetList { FeatureId = long.Parse(s.Split(new char[] { '|' }, StringSplitOptions.None)[0]), FeatureSetId = fs.Id });
                }
            }

            fs.FeatureSetList = fsList;

            service.UpdateCompanyFeatureSet(fs, featureSetListService.GetByFeatureSetId(id));

            return Json("Success");
        }
コード例 #7
0
        public JsonResult InsertCompanyFeature(long companyId, string featureName, string featureList)
        {
            #region Feature Set

            FeatureSet fs = new FeatureSet();
            fs.Name = featureName;
            fs.AccessType = AuthenticationHelper.UserRole == UserRoles.SuperAdmin.ToString() ? "company" : "user";
            fs.CompanyId = companyId;
            fs.CreateDate = DateTime.Now;
            fs.CreateBy = AuthenticationHelper.UserId;

            #region FeatureSet List
            List<FeatureSetList> fsList = new List<FeatureSetList>();
            var newValue = featureList.Replace("undefined|", "").Replace("undefined±", "").Split(new char[] { '±' }, StringSplitOptions.None);
            foreach (string s in newValue)
            {
                if (!string.IsNullOrEmpty(s))
                {
                    fsList.Add(new FeatureSetList { FeatureId = long.Parse(s.Split(new char[] { '|' }, StringSplitOptions.None)[0]), FeatureSetId = fs.Id });
                }
            }
            #endregion

            fs.FeatureSetList = fsList;

            #endregion

            #region Feature Set Access

            FeatureSetAccess fsa = new FeatureSetAccess();
            fsa.CompanyId = companyId;
            fsa.FeatureSetId = fs.Id;
            fsa.CreateDate = DateTime.Now;

            service.InsertCompanyFeatureSet(fs, fsa);

            #endregion

            return Json("Success");
        }
コード例 #8
0
 public string Insert(FeatureSet entity)
 {
     this.Context.FeatureSets.Add(entity);
     this.Commit();
     return entity.Id.ToString();
 }
コード例 #9
0
 public string Update(FeatureSet entity)
 {
     return this.repository.Update(entity);
 }
コード例 #10
0
 public string Insert(FeatureSet entity)
 {
     return this.repository.Insert(entity);
 }
コード例 #11
0
        public void UpdateCompanyFeatureSet(FeatureSet fs, IEnumerable<FeatureSetList> oldFeatureSetList)
        {
            foreach (var featureSetList in fs.FeatureSetList)
            {
                List<FeatureSetList> fls = oldFeatureSetList.Where(x => x.FeatureId == featureSetList.FeatureId && x.FeatureSetId == featureSetList.FeatureSetId)
                    .Select(a => new FeatureSetList()).ToList();

                if (fls.Count() == 0)
                {
                    string result = fslRepo.Insert(featureSetList);
                    featureSetList.Id = Convert.ToInt32(result);
                }
                else
                {
                    featureSetList.Id = fls.First().Id;
                }
            }

            List<FeatureSetList> tobeDeleted = new List<FeatureSetList>();
            foreach (var featureSetList in oldFeatureSetList)
            {
                var fls = fs.FeatureSetList.Where(x => x.FeatureId == featureSetList.FeatureId && x.FeatureSetId == featureSetList.FeatureSetId)
                    .Select(a => new FeatureSetList()).ToList();

                if (fls.Count() == 0)
                {
                    tobeDeleted.Add(featureSetList);
                    
                }
            }

            //TODO: There is already an open DataReader associated with this Command which must be closed first. on above logic..
            foreach (var item in tobeDeleted)
            {
                fslRepo.Delete(item);
            }

            fsRepo.Update(fs);
        }