/// <summary>
        /// Updates a SurveyInfo.
        /// </summary>
        /// <param name="SurveyInfo">SurveyInfo.</param>
        public void UpdateSurveyInfo(SurveyInfoBO SurveyInfo)
        {
            try
            {
                Guid Id = new Guid(SurveyInfo.SurveyId);

                //Update Survey
                using (var Context = DataObjectFactory.CreateContext())
                {
                    //var Query = from response in Context.SurveyMetaDatas
                    //            where response.SurveyId == Id
                    //            select response;

                    //var DataRow = Query.Single();
                    //DataRow = Mapper.ToEF(SurveyInfo);

                    SurveyMetaData Row = Context.SurveyMetaDatas.First(x => x.SurveyId == Id);
                    Row.IsSQLProject     = SurveyInfo.IsSqlProject;
                    Row.IsDraftMode      = SurveyInfo.IsDraftMode;
                    Row.IsShareable      = SurveyInfo.IsShareable;
                    Row.DataAccessRuleId = SurveyInfo.DataAccessRuleId;
                    Context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
        public void UpdateFormMode(FormInfoBO formInfoBO)
        {
            try
            {
                Guid Id = new Guid(formInfoBO.FormId);

                //Update Form Mode
                using (var context = DataObjectFactory.CreateContext())
                {
                    var query = from response in context.SurveyMetaDatas
                                where response.SurveyId == Id
                                select response;

                    var dataRow = query.Single();
                    dataRow.IsDraftMode      = formInfoBO.IsDraftMode;
                    dataRow.IsShareable      = formInfoBO.IsShareable;
                    dataRow.DataAccessRuleId = formInfoBO.DataAccesRuleId;

                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
Exemplo n.º 3
0
 public IList <CompanyLocation> GetLocations(int companyId)
 {
     using (var context = DataObjectFactory.CreateContext())
     {
         return(context.CompanyLocations.Where(e => e.CompanyId == companyId).Select(Mapper.Map).ToList());
     }
 }
Exemplo n.º 4
0
 /// <summary>
 /// Gets order given an order identifier.
 /// </summary>
 /// <param name="orderId">Order identifier.</param>
 /// <returns>The order.</returns>
 public Order GetOrder(int orderId)
 {
     using (var context = DataObjectFactory.CreateContext())
     {
         return(Mapper.Map(context.OrderEntities.SingleOrDefault(o => o.OrderId == orderId)));
     }
 }
        public FormSettingBO GetFormSettings()
        {
            FormSettingBO formSettingBO = new FormSettingBO();

            Dictionary <int, string>    dataAccessRuleIds         = new Dictionary <int, string>();
            Dictionary <string, string> dataAccessRuleDescription = new Dictionary <string, string>();
            int selectedDataAccessRuleId = -1;;

            try
            {
                using (var context = DataObjectFactory.CreateContext())
                {
                    ////  Available DataAccess Rule Ids  list
                    IQueryable <DataAccessRule> RuleIDs = context.DataAccessRules.ToList().AsQueryable();
                    foreach (var Rule in RuleIDs)
                    {
                        dataAccessRuleIds.Add(Rule.RuleId, Rule.RuleName);
                        dataAccessRuleDescription.Add(Rule.RuleName, Rule.RuleDescription);
                    }

                    formSettingBO.SelectedDataAccessRule    = selectedDataAccessRuleId;
                    formSettingBO.DataAccessRuleDescription = dataAccessRuleDescription;
                    formSettingBO.DataAccessRuleIds         = dataAccessRuleIds;
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
            return(formSettingBO);
        }
Exemplo n.º 6
0
 /// <summary>
 /// Gets a customer given a customer identifier.
 /// </summary>
 /// <param name="customerId">The customer identifier.</param>
 /// <returns>The customer.</returns>
 public Customer GetCustomer(int customerId)
 {
     using (var context = DataObjectFactory.CreateContext())
     {
         return(Mapper.Map(context.CustomerEntities.FirstOrDefault(c => c.CustomerId == customerId)));
     }
 }
        public List <UserBO> GetOrgAdminsByFormId(string formId)
        {
            List <UserBO>            userBOList = new List <UserBO>();
            Dictionary <int, string> orgAdmins  = new Dictionary <int, string>();
            Guid id = new Guid(formId);

            try
            {
                using (var context = DataObjectFactory.CreateContext())
                {
                    SurveyMetaData response   = context.SurveyMetaDatas.First(x => x.SurveyId == id);
                    var            orgHashSet = new HashSet <int>(response.Organizations.Select(x => x.OrganizationId));
                    var            orgs       = context.Organizations.Where(t => orgHashSet.Contains(t.OrganizationId)).ToList();

                    foreach (var org in orgs)
                    {
                        var adminList = context.UserOrganizations.Where(x => x.OrganizationID == org.OrganizationId && x.RoleId == Roles.Administrator && x.Active == true);
                        foreach (var admin in adminList)
                        {
                            UserBO userBO = new UserBO();
                            userBO.EmailAddress = admin.User.EmailAddress;
                            userBO.UserId       = admin.User.UserID;
                            userBOList.Add(userBO);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }

            return(userBOList);
        }
        public Dictionary <int, string> GetOrgAdmins(Dictionary <int, string> selectedOrgList)
        {
            Dictionary <int, string> orgAdmins = new Dictionary <int, string>();

            int i = 0;

            try
            {
                using (var context = DataObjectFactory.CreateContext())
                {
                    foreach (var org in selectedOrgList)
                    {
                        int orgId = int.Parse(org.Value);

                        var adminList = context.UserOrganizations.Where(x => x.OrganizationID == orgId && x.RoleId == Roles.Administrator && x.Active == true).ToList();

                        foreach (var item in adminList)
                        {
                            orgAdmins.Add(i, item.User.EmailAddress);
                            i++;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }

            return(orgAdmins);
        }
Exemplo n.º 9
0
 public IList <CompanyLocation> GetLocations()
 {
     using (var context = DataObjectFactory.CreateContext())
     {
         return(context.CompanyLocations.Select(Mapper.Map).ToList());
     }
 }
        public void UpdateColumnNames(FormSettingBO FormSettingBO, string FormId)
        {
            Guid Id = new Guid(FormId);

            try
            {
                using (var context = DataObjectFactory.CreateContext())
                {
                    IQueryable <ResponseDisplaySetting> ColumnList = context.ResponseDisplaySettings.Where(x => x.FormId == Id);

                    //Delete old columns
                    foreach (var item in ColumnList)
                    {
                        context.ResponseDisplaySettings.DeleteObject(item);
                    }
                    context.SaveChanges();

                    //insert new columns

                    ResponseDisplaySetting ResponseDisplaySettingEntity = new ResponseDisplaySetting();
                    foreach (var item in FormSettingBO.ColumnNameList)
                    {
                        ResponseDisplaySettingEntity = Mapper.ToColumnName(item, Id);
                        context.AddToResponseDisplaySettings(ResponseDisplaySettingEntity);
                    }
                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
Exemplo n.º 11
0
        public UserAuthenticationResponseBO GetAuthenticationResponse(UserAuthenticationRequestBO passcodeBO)
        {
            // TODO: Implement this correctly
            var userAuthenticationResponseBO = new UserAuthenticationResponseBO {
                PassCode = passcodeBO.PassCode, ResponseId = passcodeBO.ResponseId
            };

            return(userAuthenticationResponseBO);

#if false // from WebEnter
            UserAuthenticationResponseBO UserAuthenticationResponseBO = Mapper.ToAuthenticationResponseBO(UserAuthenticationRequestBO);
            try
            {
                Guid Id = new Guid(UserAuthenticationRequestBO.ResponseId);

                using (var Context = DataObjectFactory.CreateContext())
                {
                    SurveyResponse surveyResponse = Context.SurveyResponses.First(x => x.ResponseId == Id);
                    if (surveyResponse != null)
                    {
                        UserAuthenticationResponseBO.PassCode = surveyResponse.ResponsePasscode;
                    }
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
            return(UserAuthenticationResponseBO);
#endif
        }
Exemplo n.º 12
0
        private int GetUserOrganization(string surveyId, int userId)
        {
            try
            {
                int orgId = -1;
                using (var context = DataObjectFactory.CreateContext())
                {
                    // get UserOrganization
                    var items = from UserOrgInfo in context.UserOrganizations
                                join OrgInfo in context.Organizations on UserOrgInfo.OrganizationID equals OrgInfo.OrganizationId into temp

                                where UserOrgInfo.UserID == userId

                                from query in temp.DefaultIfEmpty()
                                select new { query };
                    foreach (var Item in items)
                    {
                        var oIds = Item.query.SurveyMetaDatas.Where(x => x.SurveyId == new Guid(surveyId));
                        if (oIds.Count() > 0)
                        {
                            orgId = Item.query.OrganizationId;
                            break;
                        }
                    }

                    //var OId = items.Where(x => x.query.SurveyMetaDatas.Where(z => z.SurveyId == new Guid(SurveyId)) == items1);
                }

                return(orgId);
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
Exemplo n.º 13
0
 public IList <Vendor> GetVendors()
 {
     using (var context = DataObjectFactory.CreateContext())
     {
         var vendors = context.Vendors.ToList();
         return(vendors.Select(Mapper.Map).ToList());
     }
 }
Exemplo n.º 14
0
 public CompanyLocation GetLocation(int locationId)
 {
     using (var context = DataObjectFactory.CreateContext())
     {
         var entity = context.CompanyLocations.FirstOrDefault(e => e.CompanyLocationId == locationId);
         return(entity == null ? null : Mapper.Map(entity));
     }
 }
Exemplo n.º 15
0
 public Company GetCompany(int companyId)
 {
     using (var context = DataObjectFactory.CreateContext())
     {
         var entity = context.Companies.FirstOrDefault(e => e.CompanyId == companyId);
         return(entity == null ? null : Mapper.Map(entity));
     }
 }
Exemplo n.º 16
0
 // get Vendor by id
 public Vendor GetVendorById(int vendorId)
 {
     using (var context = DataObjectFactory.CreateContext())
     {
         var entity = context.Vendors.FirstOrDefault(e => e.VendorId == vendorId);
         return(entity == null ? null : Mapper.Map(entity));
     }
 }
Exemplo n.º 17
0
 // get Employee by id
 public Employee GetEmployeeById(int employeeId)
 {
     using (var context = DataObjectFactory.CreateContext())
     {
         var entity = context.Employees.FirstOrDefault(e => e.EmployeeId == employeeId);
         return(entity == null ? null : Mapper.Map(entity));
     }
 }
Exemplo n.º 18
0
 public IList <Supplier> GetSuppliers()
 {
     using (var context = DataObjectFactory.CreateContext())
     {
         var suppliers = context.Suppliers.ToList();
         return(suppliers.Select(Mapper.Map).ToList());
     }
 }
Exemplo n.º 19
0
 // get Measure by id
 public Measure GetMeasureById(int measureId)
 {
     using (var context = DataObjectFactory.CreateContext())
     {
         var entity = context.Measures.FirstOrDefault(e => e.MeasureId == measureId);
         return(entity == null ? null : Mapper.Map(entity));
     }
 }
Exemplo n.º 20
0
 public IList <Measure> GetMeasures()
 {
     using (var context = DataObjectFactory.CreateContext())
     {
         var measures = context.Measures.ToList();
         return(measures.Select(Mapper.Map).ToList());
     }
 }
Exemplo n.º 21
0
 // get Supplier by id
 public Supplier GetSupplierById(int supplierId)
 {
     using (var context = DataObjectFactory.CreateContext())
     {
         var entity = context.Suppliers.FirstOrDefault(e => e.SupplierId == supplierId);
         return(entity == null ? null : Mapper.Map(entity));
     }
 }
Exemplo n.º 22
0
 public IList <Employee> GetEmployees()
 {
     using (var context = DataObjectFactory.CreateContext())
     {
         var employees = context.Employees.ToList();
         return(employees.Select(Mapper.Map).ToList());
     }
 }
Exemplo n.º 23
0
 /// <summary>
 /// Gets a product given a product identifier.
 /// </summary>
 /// <param name="productId">Product identifier.</param>
 /// <returns>The product.</returns>
 public Product GetProduct(int productId)
 {
     using (var context = DataObjectFactory.CreateContext())
     {
         return(Mapper.Map(context.ProductEntities
                           .SingleOrDefault(p => p.ProductId == productId)));
     }
 }
Exemplo n.º 24
0
 // get Currency by id
 public Currency GetCurrencyById(int currencyId)
 {
     using (var context = DataObjectFactory.CreateContext())
     {
         var entity = context.Currencys.FirstOrDefault(e => e.CurrencyId == currencyId);
         return(entity == null ? null : Mapper.Map(entity));
     }
 }
Exemplo n.º 25
0
 public IList <Currency> GetCurrencys()
 {
     using (var context = DataObjectFactory.CreateContext())
     {
         var currencys = context.Currencys.ToList();
         return(currencys.Select(Mapper.Map).ToList());
     }
 }
Exemplo n.º 26
0
 // get product by id
 public Product GetProduct(int productId)
 {
     using (var context = DataObjectFactory.CreateContext())
     {
         var entity = context.Products.FirstOrDefault(e => e.ProductId == productId);
         return(entity == null ? null : Mapper.Map(entity));
     }
 }
Exemplo n.º 27
0
 // get all products
 public List <Product> GetProducts()
 {
     using (var context = DataObjectFactory.CreateContext())
     {
         var products = context.Products.ToList();
         return(products.Select(Mapper.Map).ToList());
     }
 }
Exemplo n.º 28
0
 public int DeleteCurrency(int id = 0)
 {
     using (var context = DataObjectFactory.CreateContext())
     {
         var entity = context.Currencys.FirstOrDefault(s => s.CurrencyId == id);
         context.Currencys.Remove(entity);
         return(context.SaveChanges());
     }
 }
Exemplo n.º 29
0
 /// <summary>
 /// Update existing student
 /// </summary>
 /// <param name="id">Unique student identifier</param>
 /// <param name="student">Unique student object</param>
 public void PatchStudent(int id, Student student)
 {
     using (var context = DataObjectFactory.CreateContext())
     {
         var entity = context.Students.Where(s => s.StudentId == id).FirstOrDefault();
         entity.StudentName = student.StudentName;
         context.SaveChanges();
     }
 }
Exemplo n.º 30
0
 /// <summary>
 /// Deletes a customer record from the database.
 /// </summary>
 /// <param name="customer">The customer to be deleted.</param>
 /// <returns>Number of rows affected.</returns>
 public void DeleteCustomer(Customer customer)
 {
     using (var context = DataObjectFactory.CreateContext())
     {
         var entity = context.CustomerEntities.Where(c => c.CustomerId == customer.CustomerId).SingleOrDefault();
         context.CustomerEntities.DeleteObject(entity);
         context.SaveChanges();
     }
 }