Exemple #1
0
        /// <summary>
        /// Register providers from user settings, where they were previously saved.
        /// </summary>
        public async Task RestoreProviders()
        {
            // Load available IProvider types into memory
            if (ProviderService.Available.Count == 0)
            {
                ProviderService.LoadProviders();
            }

            var tasks = new Dictionary <string, Task <bool> >();

            // ToList() is needed because the original Dictionary is changing while we iterating
            SettingsService.Current.SafeProviders
            .ToList()
            .ForEach(p => tasks[p.Key] = ProviderService.RegisterProvider(
                         ProviderService.GetProviderById(p.Value.Id), p.Key, p.Value.State, false));

            // Wait for tasks to finish and remove unloaded providers
            foreach (var task in tasks)
            {
                if (!ProviderService.Loaded.ContainsKey(task.Key) && !await task.Value)
                {
                    ToastService.Create(string.Format(Resources.ProviderRegistrationFailed, task.Key));
                    ProviderService.ClearProvider(task.Key);
                }
            }
        }
Exemple #2
0
        public ActionResult Details(int id)
        {
            var service = new ProviderService();
            var model   = service.GetProviderById(id);

            return(View(model));
        }
Exemple #3
0
        public ActionResult SearchImport()
        {
            try
            {
                var table    = new StringBuilder();
                var datefrom = DateTime.ParseExact(Request["DateFrom"], "dd/MM/yyyy", null);
                var dateto   = DateTime.ParseExact(Request["DateTo"], "dd/MM/yyyy", null);
                var iService = new ImportService();
                var pService = new ProviderService();
                var tService = new StockService();
                var imports  = iService.GetExportByDate(datefrom, dateto);


                table.Append("<table id='table1' class='table1'>");
                table.Append("<thead>");
                table.Append("<tr>");
                table.Append("<th>Nhà cung cấp</th>");
                table.Append("<th>Ngày giờ</th>");
                table.Append("<th>Tên kho</th>");
                table.Append("</tr>");
                table.Append("</thead>");

                table.Append("<tbody>");
                foreach (var import in imports)
                {
                    var provider = pService.GetProviderById(import.ProviderId);
                    var stock    = tService.GetStockById(import.StockId);
                    table.Append("<tr>");
                    table.AppendFormat("<td>{0}</td>", provider.Name);
                    table.AppendFormat("<td>{0}</td>", import.CreatedDate.ToShortDateString());
                    table.AppendFormat("<td>{0}</td>", stock.Name);
                    table.Append("</tr>");
                }


                table.Append("</tbody>");
                table.Append("</table>");

                return(Json(new
                {
                    finish = true,
                    data = table.ToString()
                }));
            }
            catch (Exception e)
            {
                return(Json(new { finish = false, data = e.ToString() }));
            }
        }
Exemple #4
0
        //GET: Edit
        public ActionResult Edit(int id)
        {
            var service = new ProviderService();
            var detail  = service.GetProviderById(id);
            var model   = new ProviderEdit
            {
                ProviderId     = detail.ProviderId,
                FirstName      = detail.FirstName,
                LastName       = detail.LastName,
                Title          = detail.Title,
                ImageAsBytes   = detail.ImageAsBytes,
                ImageFile      = detail.ImageFile,
                License        = detail.License,
                Specialization = detail.Specialization,
                ClinicId       = detail.ClinicId,
                UserId         = detail.UserId
            };

            return(View(model));
        }