public void AddUserDataSet(int? UserId, int DataSetId, int ValidityPeriod, DateTime? UsedDateTime)
        {

            try
            {
                UserDataSet Uds;
                using (var dbContext = new ePharmaGuideContext())
                {
                    Uds = dbContext.UserDataSets.FirstOrDefault(s => s.DataSetId == DataSetId && s.UserId == UserId && s.isDisabled == false);

                    if (Uds == null)
                    {
                        var AddUserDataSet = new UserDataSet
                        {
                            DateCreated = DateTime.Now,
                            DateModified = DateTime.Now,
                            DateSubscribed = UsedDateTime.Value.AddDays(ValidityPeriod),
                            DataSetId = DataSetId,
                            UserId = UserId.Value,
                            ValidityPeriod = ValidityPeriod
                        };
                        dbContext.UserDataSets.Add(AddUserDataSet);
                        dbContext.SaveChanges();
                    }

                    else 
                    {
                        if (Uds.DateSubscribed < DateTime.Now || Uds.isDisabled)
                        {
                            Uds.DateSubscribed = DateTime.Now.AddDays(ValidityPeriod);
                            Uds.DateModified = DateTime.Now;
                            Uds.ValidityPeriod = ValidityPeriod;

                            dbContext.Entry(Uds).State = System.Data.Entity.EntityState.Modified;
                            dbContext.SaveChanges();
                        }

                        else
                        {
                            Uds.DateSubscribed = Uds.DateSubscribed.AddDays(ValidityPeriod);
                            Uds.DateModified = DateTime.Now;
                            Uds.ValidityPeriod = ValidityPeriod;

                            dbContext.Entry(Uds).State = System.Data.Entity.EntityState.Modified;
                            dbContext.SaveChanges();
                        }
                    }
                }

            }
            catch (Exception ex)
            {
                throw;
            }
        }
        public void AddData(int UserId, int DataSetId)
        {
            using (var dbContext = new ePharmaGuideContext())
            {
                UserDataSet Uds;

                var AddUserDataSet = new UserDataSet
                {
                    DateCreated = DateTime.Now,
                    DateModified = DateTime.Now,
                    DateSubscribed = new DateTime(4015, 12, 1),
                    DataSetId = DataSetId,
                    UserId = UserId,
                    ValidityPeriod = -1
                };
                dbContext.UserDataSets.Add(AddUserDataSet);
                dbContext.SaveChanges();
            }
        }