public virtual ActionResult TestEmail()
        {
            LogI("TestEmail");
            var company      = AccessManager.Company;
            var smtpSettings = CompanyHelper.GetSmtpSettings(company);
            var byName       = AccessManager.UserName;

            var result = ComposeEmailViewModel.FromTemplate(Db,
                                                            EmailService,
                                                            String.Empty,
                                                            company,
                                                            byName,
                                                            EmailTypes.System,
                                                            smtpSettings);

            var model = new ComposeEmailViewModel();

            if (result.Status == CallStatus.Success)
            {
                model = result.Data;
            }


            model.Subject = "Check email from web page";
            model.ToEmail = "*****@*****.**";
            model.ToName  = "Support";


            return(View("ComposeEmail", model));
        }
Example #2
0
        public async Task <JsonResult> Put(int id, [FromBody] CompanyHelper company)
        {
            //Viewmodel validations
            if (!ModelState.IsValid)
            {
                return(new JsonResult(ModelState)
                {
                    StatusCode = (int)HttpStatusCode.BadRequest
                });
            }

            var _company = await _context.Companies.FindAsync(id);

            //Return if error
            if (_company == null)
            {
                return(new JsonResult
                           ("Company doesn't exist or has been deleted")
                {
                    StatusCode = (int)HttpStatusCode.NotFound
                });
            }

            _company.Name        = company.Name;
            _company.Description = company.Description;
            await _context.SaveChangesAsync();

            return(new JsonResult(_company)
            {
                StatusCode = (int)HttpStatusCode.OK
            });
        }
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            Company company = new Company(textBoxName.Text, textBoxWeb.Text, textBoxCUIT.Text, addresses, phones, toStringList(emails));

            Tuple <HttpStatusCode, string> response = CompanyHelper.sendToDB(company);

            JObject jres = JObject.Parse(response.Item2);

            if (response.Item1 == HttpStatusCode.OK && jres.ContainsKey(DBKeys.Company.ID))
            {
                MessageBox.Show("Se guardó correctamente");
                btnClear_Click(btnClear, null);
            }

            else
            {
                MessageBox.Show("No se pudo guardar");
            }
            //SaveFileDialog saveFileDialog = new SaveFileDialog();
            //saveFileDialog.Filter = "Texto|*.txt";
            //saveFileDialog.ShowDialog();
            //if (saveFileDialog.FileName != "")
            //{
            //    System.IO.File.AppendAllText(saveFileDialog.FileName, company.toJSON().ToString());
            //}
        }
        public ActionResult AddComment(string content, string userId, int companyId)
        {
            Comment toAdd = new Comment()
            {
                AuthorId    = userId,
                Content     = mark.Transform(content),
                CompanyId   = companyId,
                VoteCount   = 0,
                ReleaseDate = DateTime.Now
            };
            Company company = context.Companies.Find(companyId);

            company.LastUpdate = DateTime.Now;
            context.Comments.Add(toAdd);
            context.SaveChanges();
            CompanyViewModel model = new CompanyViewModel()
            {
                Company = company,
                User    = context.ApplicationUsers.Find(userId),

                Tags     = CompanyHelper.GetAllCompanyTags(companyId, context),
                Comments = context.Comments.Where(c => c.CompanyId == companyId).ToList(),
                Context  = context
            };

            return(View("Company", model));
        }
Example #5
0
        public Response updateCompany(string token, [FromBody] Aden.Model.Common.Company lines)
        {
            Response response = new Response();

            if (string.IsNullOrEmpty(token) || !token.Equals(_token))
            {
                response.code    = "404";
                response.message = "Invalid token";
            }
            else
            {
                int intExCount = 0;
                intExCount = CompanyHelper.updateCompany(lines);

                if (intExCount == 0)
                {
                    response.code    = "500";
                    response.message = "process failed";
                }
                else
                {
                    response.code = "200";
                }
            }
            return(response);
        }
        public IActionResult LikeComment(string userId, int commentId, string path)
        {
            Comment comment = context.Comments.Find(commentId);

            if (context.Votes.Where(c => c.CommentId == commentId && c.UserId == userId).ToList().Count == 0)
            {
                comment.VoteCount++;
                Vote vote = new Vote()
                {
                    CommentId = commentId,
                    UserId    = userId,
                };
                context.Votes.Add(vote);
            }
            Company company = context.Companies.Find(comment.CompanyId);

            context.SaveChanges();
            CompanyViewModel model = new CompanyViewModel()
            {
                Company  = company,
                User     = context.ApplicationUsers.Find(userId),
                Tags     = CompanyHelper.GetAllManualTags(company.CompanyId, context),
                Comments = context.Comments.Where(c => c.CompanyId == company.CompanyId).ToList(),
                Context  = context
            };

            return(View("Company", model));
        }
Example #7
0
        public async Task <JsonResult> Post([FromForm] CompanyHelper company)
        {
            //Viewmodel validations
            if (!ModelState.IsValid)
            {
                return(new JsonResult(ModelState)
                {
                    StatusCode = (int)HttpStatusCode.BadRequest
                });
            }

            string picture = await _imageHandler.UploadImage(company.Logo);

            //Creating the entity
            var _company = new Company()
            {
                Description = company.Description,
                Name        = company.Name,
                Logo        = picture
            };

            //Finally add
            await _context.Companies.AddAsync(_company);

            await _context.SaveChangesAsync();

            return(new JsonResult(_company)
            {
                StatusCode = (int)HttpStatusCode.OK
            });
        }
        public async Task <ClientConfiguration> GetConfigurationAsync()
        {
            // IIS web site names should be predefined correctly
            string host     = HostingEnvironment.ApplicationHost.GetSiteName();
            Guid   clientId = CompanyHelper.GetCompanyIdByHost(host);

            ClientConfigurationDto configurationDto = _cacheConfigurationRepository.GetByClientId(clientId);

            if (configurationDto != null)
            {
                return(MapClientConfigurationDtoToClientConfiguration(configurationDto));
            }

            configurationDto = await _dbConfigurationRepository.GetByClientIdAsync(clientId);

            List <string> activeModules = await _dbConfigurationRepository.GetActiveModulesByClientIdAsync(clientId);

            if (configurationDto == null || activeModules == null || activeModules.Count == 0)
            {
                throw new ConfigurationErrorsException($"Configuration for the {host} was not found");
            }

            configurationDto.ActiveModules = string.Join(",", activeModules);

            _cacheConfigurationRepository.CreateConfiguration(configurationDto);

            return(MapClientConfigurationDtoToClientConfiguration(configurationDto));
        }
Example #9
0
        protected void Application_BeginRequest(Object source, EventArgs e)
        {
            string host      = HttpContext.Current.Request.Url.Host;
            Guid   companyId = CompanyHelper.GetCompanyIdByHost(host);

            HttpContext.Current.Request.Headers.Add("CompanyId", companyId.ToString());
        }
        public virtual ActionResult GetBalance()
        {
            LogI("GetBalance");

            var companyId = AccessManager.CompanyId;

            if (!companyId.HasValue)
            {
                throw new ArgumentNullException("CompanyId");
            }

            var shipmentProviders = ServiceFactory.GetShipmentProviders(LogService,
                                                                        Time,
                                                                        DbFactory,
                                                                        WeightService,
                                                                        AccessManager.Company.ShipmentProviderInfoList,
                                                                        null,
                                                                        null,
                                                                        null,
                                                                        null);

            CompanyHelper.UpdateBalance(Db, AccessManager.Company, shipmentProviders, true, Time.GetAppNowTime());

            var model = new AccountStatusViewModel(AccessManager.Company);

            return(new JsonResult
            {
                Data = ValueResult <ShipmentProviderViewModel[]> .Success("", model.ShipmentProviderList.ToArray()),
                JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
Example #11
0
        public Response CheckSupplierCode(string token, [FromBody] Company companyInfo)
        {
            Response response = new Response();

            if (string.IsNullOrEmpty(token) || !token.Equals(_token))
            {
                response.code    = "404";
                response.message = "Invalid token";
            }
            else
            {
                try
                {
                    bool result = CompanyHelper.CheckSupplierCode(companyInfo);

                    response.code    = "200";
                    response.content = result;
                }
                catch
                {
                    response.code    = "500";
                    response.content = "process failed";
                }
            }
            return(response);
        }
Example #12
0
        public Response GetCompany(string token, [FromBody] AuthCompany auth)
        {
            Response response = new Response();

            if (string.IsNullOrEmpty(token) || !token.Equals(_token))
            {
                response.code    = "404";
                response.message = "Invild token";
            }
            else
            {
                var data = CompanyHelper.GetCompany(auth);
                if (data == null)
                {
                    response.code    = "500";
                    response.message = "No Data";
                }
                else
                {
                    response.code    = "200";
                    response.content = data;
                }
            }
            return(response);
        }
Example #13
0
 public Index()
 {
     InitializeComponent();
     _deptHelper          = new DeptHelper();
     _companyHelper       = new CompanyHelper();
     _assetCategoryHelper = new AssetCategoryHelper();
     _assetHelper         = new AssetHelper();
 }
        private void initDeviceAlarmDBTable()
        {
            foreach (var item in _companyMap)
            {
                CompanyHelper companyItem = item.Value;

                ((CompanyHelper)item.Value).UpdateAllDeviceStatus();
            }
        }
        public ActionResult Index(string message = "")
        {
            ViewBag.ErrorMessage = message;
            CompanyListModel model = new CompanyListModel();

            model.Companies = CompanyHelper.GetCompanies();
            AuthenticationHelper.CompanyList = model.Companies;
            return(View(model));
        }
Example #16
0
        private void dataGridCompany_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            //MessageBox.Show(((Company)dataGridCompany.SelectedItem).getFullDescription());
            DataRowView row     = dataGridCompany.SelectedItem as DataRowView;
            int         itemId  = int.Parse(row.Row.ItemArray[0].ToString());
            Company     company = CompanyHelper.GetCompany(itemId);

            MessageBox.Show(company.getData(), company.getTitle());
            //CustomMessageBox
        }
        //public ActionResult MyCompany()
        //{
        //    List<CompanyIndexViewModel> vmodel = new List<CompanyIndexViewModel>();
        //    var userId = User.Identity.GetUserId();
        //    List<Company> companies = db.Users.Find(userId).Company.ToList();

        //    //var companyIdList = db.Companies.Where( c => c.Id == )
        //    //List<Company> companies = db.Users.Find(userId).Company.ToList();



        //    foreach (Company company in companies)
        //    {
        //        CompanyIndexViewModel vm = new CompanyIndexViewModel()
        //        {
        //            Company = company,
        //            CompanyAdmin = db.Users.Find(company.CompanyAdmin),
        //            UserId = userId
        //        };
        //        vmodel.Add(vm);
        //    }
        //    return View(vmodel);

        //    //var userId = User.Identity.GetUserId();

        //    //var userCompId = db.Users.Where( u => u.Company.Where( c => c.))

        //    //var company = db.Users.Find(userId).Company;

        //    //if (User.IsInRole("CompanyAdmin" ) || User.IsInRole("Admin"))
        //    //{
        //    //    var myCompany = db.Companies.Where(c => c.CompanyAdmin.Id == userId).ToList();
        //    //    return View(myCompany);
        //    //}

        //    ////if (User.IsInRole("Therapist"))
        //    ////{
        //    ////    var myCompany = db.Companies.Where(c => c.Id ==
        //    ////    return View(myCompany);
        //    ////}


        //    //else //temperory test if redirect works
        //    //{
        //    //    return RedirectToAction("Index", "Home");
        //    //}
        //}

        //GET: AddUser
        public ActionResult AddToCompany(int id)
        {
            var           company      = db.Companies.Find(id);
            AdminCompany  AdminCompany = new AdminCompany();
            CompanyHelper helper       = new CompanyHelper();
            var           selected     = company.Users;

            AdminCompany.Users   = new MultiSelectList(db.Users, "Id", "FullName", selected);
            AdminCompany.Company = company;
            return(View(AdminCompany));
        }
        public ActionResult AddToCompany(AdminCompany model)
        {
            CompanyHelper helper = new CompanyHelper();


            foreach (var useradd in model.SelectedUsers)
            {
                helper.AddUserToCompany(useradd, model.Company.Id);
            }
            return(RedirectToAction("Index", "AdminCompanies"));
        }
        public IHttpActionResult PostCompany(CompanyHelper company)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            db.Companies.Add(company.company);
            db.SaveChanges();

            return(Ok(new { company = company.company }));
        }
 public ActionResult Delete(string id)
 {
     try
     {
         CompanyHelper.DeleteCompany(id);
         return(RedirectToAction("Index"));
     }
     catch (Exception ex)
     {
         return(RedirectToAction("Index", new { message = ex.Message }));
     }
 }
Example #21
0
        public ActionResult Edit()
        {
            var    user       = Membership.GetUser();
            string userRowKey = (user.ProviderUserKey as string);
            var    company    = new CompanyRepository().GetByRowKey(userRowKey);

            var chamberArray = CompanyHelper.GetAllCompaniesFromCache().Where(c => c.BusinessType != null).Where(c => c.BusinessType.ToLower() == "chamber").ToArray();

            ViewBag.ChamberArray = chamberArray;

            if (company == null)
            {
                company = new CompanyModel(userRowKey, "New Company Name", user.Email, user.Email, string.Empty);
            }

            if (company.LogoUrl == null)
            {
                company.LogoUrl = "_blank";
            }

            if (company.BusinessType == null)
            {
                company.BusinessType = "Association";
            }

            if (company.BusinessType.ToLower() == "chamber")
            {
                var subscribeUrl      = @"http://matchmakerapplication.cloudapp.net/Company/RegisterAsChamberCertified?key=" + chamberHash + "&id=" + Url.Encode(company.RowKey);
                var greenSubscribeUrl = @"http://matchmakerapplication.cloudapp.net/Company/RegisterAsGreenCertified?key=" + greenHash;

                ViewBag.ShowUpgradeLink = false;
                return(MenuView(new CompanyViewModel {
                    CompanyData = company, IsChamber = true, ChamberSubscribeUrl = subscribeUrl, GreenSubscribeUrl = greenSubscribeUrl
                }, "MY PROFILE", "SubMenuMyProfile", "Company Profile"));
            }
            else
            {
                var subscription = new CompanySubscriptionRepository().GetByRowKey(company.RowKey);

                if (subscription == null)
                {
                    ViewBag.ShowUpgradeLink = true;
                }
                else
                {
                    ViewBag.ShowUpgradeLink = false;
                }

                return(MenuView(new CompanyViewModel {
                    CompanyData = company, IsChamber = false, ChamberSubscribeUrl = string.Empty
                }, "MY PROFILE", "SubMenuMyProfile", "Company Profile"));
            }
        }
Example #22
0
        private void DelEmptyTags(int id, ApplicationDbContext context)
        {
            List <CompanyTag> manualTags = CompanyHelper.GetCompanyTags(id, context);

            foreach (CompanyTag mTag in manualTags)
            {
                if (CompanyHelper.CountSameNameCompanyTags(mTag.CompanyTagId, context) < 2)
                {
                    context.Tags.Remove(context.Tags.Find(mTag.TagId));
                }
            }
            context.SaveChanges();
        }
Example #23
0
        private void loadCompanies()
        {
            List <Company> allCompanies   = CompanyHelper.GetCompanies();
            List <Company> companiesCombo = new List <Company>();

            foreach (Company item in allCompanies)
            {
                if (!companies.Contains(item))
                {
                    companiesCombo.Add(item);
                }
            }
            comboCompany.ItemsSource   = companiesCombo;
            comboCompany.SelectedIndex = -1;
        }
Example #24
0
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            comboBrand.ItemsSource = BrandHelper.GetBrands();

            comboUnits.ItemsSource = UnitHelper.GetUnits();

            comboTitle.ItemsSource = TitleHelper.GetTitles();

            comboCompany.ItemsSource = CompanyHelper.GetCompanies();

            comboShop.ItemsSource = ShopHelper.GetShops();

            dataGridCompanies.HeadersVisibility = DataGridHeadersVisibility.None;

            loadCompanies();
        }
Example #25
0
        public bool Initialize(CompanyHelper ParentCompanyHelper)
        {
            _parentCompanyHelper = ParentCompanyHelper;

            RedisDB      = _parentCompanyHelper.GetCompanyInfo().Redis.DB;
            _redisClient = RedisManager.GetClient();
            _redisClient.Select(RedisDB);
            _ThreadExitFalg       = true;
            _companyAlarmListName = $"[AlarmList]-[{_parentCompanyHelper.GetCompanyInfo().CompanyCode}]";

            _realtimeAlarmHelper.InitRealtimeAlarmHelper(ParentCompanyHelper.GetCompanyInfo().CompanyCode,
                                                         ParentCompanyHelper.GetCompanyDatabaseName());


            return(true);
        }
        public MoesifMiddlewareNetFramework(OwinMiddleware next, Dictionary <string, object> _middleware) : base(next)
        {
            moesifOptions = _middleware;

            try
            {
                // Initialize client
                debug                    = LoggerHelper.GetConfigBoolValues(moesifOptions, "LocalDebug", false);
                client                   = new MoesifApiClient(moesifOptions["ApplicationId"].ToString(), "moesif-netframework/1.3.8", debug);
                logBody                  = LoggerHelper.GetConfigBoolValues(moesifOptions, "LogBody", true);
                isBatchingEnabled        = LoggerHelper.GetConfigBoolValues(moesifOptions, "EnableBatching", true);         // Enable batching
                disableStreamOverride    = LoggerHelper.GetConfigBoolValues(moesifOptions, "DisableStreamOverride", false); // Reset Request Body position
                batchSize                = LoggerHelper.GetConfigIntValues(moesifOptions, "BatchSize", 25);                 // Batch Size
                queueSize                = LoggerHelper.GetConfigIntValues(moesifOptions, "QueueSize", 1000);               // Event Queue Size
                batchMaxTime             = LoggerHelper.GetConfigIntValues(moesifOptions, "batchMaxTime", 2);               // Batch max time in seconds
                appConfigSyncTime        = LoggerHelper.GetConfigIntValues(moesifOptions, "appConfigSyncTime", 300);        // App config sync time in seconds
                appConfig                = new AppConfig();                                                                 // Create a new instance of AppConfig
                userHelper               = new UserHelper();                                                                // Create a new instance of userHelper
                companyHelper            = new CompanyHelper();                                                             // Create a new instane of companyHelper
                clientIpHelper           = new ClientIp();                                                                  // Create a new instance of client Ip
                authorizationHeaderName  = LoggerHelper.GetConfigStringValues(moesifOptions, "AuthorizationHeaderName", "authorization");
                authorizationUserIdField = LoggerHelper.GetConfigStringValues(moesifOptions, "AuthorizationUserIdField", "sub");
                samplingPercentage       = 100;                   // Default sampling percentage
                configETag               = null;                  // Default configETag
                lastUpdatedTime          = DateTime.UtcNow;       // Default lastUpdatedTime

                MoesifQueue = new ConcurrentQueue <EventModel>(); // Initialize queue

                new Thread(async() =>                             // Create a new thread to read the queue and send event to moesif
                {
                    Thread.CurrentThread.IsBackground = true;
                    if (isBatchingEnabled)
                    {
                        ScheduleWorker();
                    }
                    else
                    {
                        ScheduleAppConfig(); // Scheduler to fetch application configuration every 5 minutes
                    }
                }).Start();
            }
            catch (Exception e)
            {
                throw new Exception("Please provide the application Id to send events to Moesif");
            }
        }
        public ActionResult Edit(CompanyModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    string result = CompanyHelper.SaveCompany(model);
                    return(RedirectToAction("Index"));
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError("Error", ex.Message);
                }
            }

            return(View(model));
        }
Example #28
0
        public ActionResult Save(CompanyEntity companyEntity)
        {
            string FileName      = "";
            string FileExtension = "";
            string UploadPath    = "";

            if (companyEntity.ImageFile != null)
            {
                //Use Namespace called :  System.IO
                FileName = Path.GetFileNameWithoutExtension(companyEntity.ImageFile.FileName);

                //To Get File Extension
                FileExtension = Path.GetExtension(companyEntity.ImageFile.FileName);

                //Add Current Date To Attached File Name
                FileName = DateTime.Now.ToString("MM-dd-yyyy-HH-mm-ss") + "-" + FileName.Trim() + FileExtension;

                //Get Upload path from Web.Config file AppSettings.
                //string UploadPath = ConfigurationManager.AppSettings["UserImagePath"].ToString();
                UploadPath = Server.MapPath("~/CompanyLogo/");

                //Its Create complete path to store in server.
                companyEntity.LogoPath = UploadPath + FileName;

                //To copy and save file into server.
                companyEntity.ImageFile.SaveAs(companyEntity.LogoPath);
            }



            ViewBag.CountryList        = CountryHelper.GetCountryData();
            ViewBag.StateByCountryList = StateByCountryHelper.GetStateByCountryData("0");

            bool saveStatus;

            companyEntity.IsActive    = true;
            companyEntity.CreatedDate = DateTime.Now;
            companyEntity.CreatedBy   = 1;
            companyEntity.is_default  = 1;
            companyEntity.ImageFile   = null;                        //TO UPDATE MODEL SO THAT IT CAN BE SEND AS STRING TO API//
            companyEntity.LogoPath    = "~/CompanyLogo/" + FileName; //TO RESET THE FULL PATH ONLY TO FOLDER AND IMAGE NAME//

            companyEntity      = CompanyHelper.SaveCompanyData(companyEntity, out saveStatus);
            ViewBag.SaveStatus = saveStatus;
            return(View("Index", companyEntity));
        }
Example #29
0
        public PartialViewResult GetCategoryFilterAsPartialView(string parentID, bool showProductCount = true)
        {
            string id = parentID;

            if (id == null)
            {
                id = "0";
            }

            var viewModel     = new CategoryViewModel();
            var categoryArray = CategoryHelper.GetAllCategoriesFromCache().ToArray();

            var parentCategory = (from parent in categoryArray
                                  where parent.RowKey == id
                                  select parent).SingleOrDefault();//null if 'All Categories'

            if (parentID != null)
            {
                viewModel.Parent = parentCategory;
            }
            else
            {
                viewModel.Parent = CategoryHelper.AllCategories;
                parentCategory   = viewModel.Parent;
            }

            var childCategoryArray = (from child in categoryArray
                                      where child.ParentID == id
                                      select child).ToArray();

            //populate viewmodel Category list with all decendants of parent
            viewModel.CategoryCollection = CategoryHelper.GetAllDescendants(parentCategory.RowKey, categoryArray, childCategoryArray).OrderBy(c => c.Parent.Name).ToList();

            //force viewmodel to populate product count (this action is recursive for all sub cateogries)
            viewModel.PopulateProductCount(
                ProductHelper.GetAllProductsFromCache().ToArray(),
                CategoryHelper.GetAllCategoriesFromCache().ToArray(),
                CompanyHelper.GetAllCompaniesFromCache().ToArray()
                );

            ViewBag.ShowproductCount = showProductCount;

            return(PartialView(viewModel));
        }
        public async Task <IActionResult> Company(int id, string userid)
        {
            //var user = await _userManager.FindByIdAsync(userid);
            var user = await _userManager.GetUserAsync(User);

            Company company = context.Companies.Find(id);

            ViewBag.userid = userid;
            CompanyViewModel model = new CompanyViewModel
            {
                Company  = company,
                Comments = context.Comments.Where(c => c.CompanyId == company.CompanyId).ToList(),
                User     = user,
                Context  = context,
                Tags     = CompanyHelper.GetAllCompanyTags(id, context)
            };

            return(View(model));
        }