コード例 #1
0
        public ProviderViewModel DestroyProvider(ProviderViewModel provider)
        {
            var providerIdToInt = int.Parse(provider.Id.ToString());
            this.Data.Providers.Delete(providerIdToInt);
            this.Data.SaveChanges();

            return provider;
        }
        public JsonResult DestroyProvider([DataSourceRequest] DataSourceRequest request, ProviderViewModel provider)
        {
            var deletedProvider = this.providers.DestroyProvider(provider);

            var loggedUserId = this.User.Identity.GetUserId();
            Base.CreateActivity(ActivityType.Delete, deletedProvider.Id.ToString(), ActivityTargetType.Provider, loggedUserId);

            return Json(new[] { provider }, JsonRequestBehavior.AllowGet);
        }
コード例 #3
0
        public async Task <IActionResult> Create(ProviderViewModel obj)
        {
            obj.DocumentNumber = obj.DocumentNumber.Replace(".", "").Replace("-", "").Replace("/", "");

            var provider = _mapper.Map <Provider>(obj);
            await _providerService.Insert(provider);

            if (!ValidOperation())
            {
                return(View(obj));
            }

            TempData["Success"] = "Fornecedor cadastrado com sucesso.";
            return(RedirectToAction(nameof(Index)));
        }
コード例 #4
0
        public ActionResult CreateProvider()
        {
            var administrations = this.AdministrationService.GetAll().Select(x => new SelectListItem()
            {
                Value = x.Id.ToString(),
                Text  = x.Name
            });

            var userViewModel = new ProviderViewModel()
            {
                Administrations = administrations
            };

            return(View(userViewModel));
        }
コード例 #5
0
        public static Provider FromViewModel(this ProviderViewModel viewModel)
        {
            Repositories.Entities.Enums.ProviderType type;
            Enum.TryParse(viewModel.Type.ToString(), out type);

            return(new Provider
            {
                UnitPrice = viewModel.UnitPrice,
                UniqueId = viewModel.ProviderId,
                Name = viewModel.Name,
                CUI = viewModel.CUI,
                BankAccount = viewModel.BankAccount,
                Type = type
            });
        }
コード例 #6
0
        public void Validate_Succeeds_With_Or_Without_ImageDomain(string imgDomain)
        {
            var model = new ProviderViewModel
            {
                ApiKey      = "key",
                ApiUrl      = "https://no.where",
                Name        = "New Provider",
                ImageDomain = imgDomain
            };

            var results = _validator.Validate(model);

            Assert.True(results.IsValid);
            Assert.Empty(results.Errors);
        }
コード例 #7
0
        public ActionResult Upsert(Guid?id)
        {
            ProviderViewModel model = null;

            if (id != null)
            {
                using (ContextManager.NewConnection())
                {
                    model = Mapper.Map <ProviderViewModel>(providerService.Get(id.Value, true));
                }
            }

            InitUpsertBreadcrumb(model);
            return(View(model));
        }
コード例 #8
0
        public void Validate_Fails_When_The_ImageDomain_Is_Not_A_Domain()
        {
            var model = new ProviderViewModel
            {
                ApiKey      = "key",
                ApiUrl      = "https://no.where",
                Name        = "New Provider",
                ImageDomain = "nope"
            };

            var results = _validator.Validate(model);

            Assert.False(results.IsValid);
            Assert.Contains(results.Errors, e => e.ErrorMessage == "Image domain is not valid.");
        }
        public virtual ActionResult TKSingleSearch(string Name, string IdentificationNumber)
        {
            ProviderViewModel oModel = new ProviderViewModel();

            oModel.RelatedThirdKnowledge = new ThirdKnowledgeViewModel();
            List <PlanModel> oCurrentPeriodList = new List <PlanModel>();

            try
            {
                oModel.ProviderMenu = GetThirdKnowledgeControllerMenu();

                //Clean the season url saved
                if (SessionModel.CurrentURL != null)
                {
                    SessionModel.CurrentURL = null;
                }

                //Get The Active Plan By Customer
                oCurrentPeriodList = ProveedoresOnLine.ThirdKnowledge.Controller.ThirdKnowledgeModule.GetCurrenPeriod(SessionModel.CurrentCompany.CompanyPublicId, true);

                if (oCurrentPeriodList != null && oCurrentPeriodList.Count > 0)
                {
                    oModel.RelatedThirdKnowledge.HasPlan = true;
                    if (!string.IsNullOrEmpty(Name) || !string.IsNullOrEmpty(IdentificationNumber))
                    {
                        oModel.RelatedThirdKnowledge.SearchNameParam     = Name;
                        oModel.RelatedThirdKnowledge.SearchIdNumberParam = IdentificationNumber;
                        oModel.RelatedThirdKnowledge.ReSearch            = true;
                    }
                    else
                    {
                        oModel.RelatedThirdKnowledge.ReSearch = false;
                    }

                    //Get The Most Recently Period When Plan is More Than One
                    oModel.RelatedThirdKnowledge.CurrentPlanModel = oCurrentPeriodList.OrderByDescending(x => x.CreateDate).First();
                }
                else
                {
                    oModel.RelatedThirdKnowledge.HasPlan = false;
                }
                return(View(oModel));
            }
            catch (Exception ex)
            {
                throw ex.InnerException;
            }
        }
        public virtual ActionResult TKThirdKnowledgeSearch(string PageNumber, string InitDate, string EndDate, string SearchType, string Status)
        {
            ProviderViewModel oModel = new ProviderViewModel();

            oModel.RelatedThidKnowledgeSearch = new ThirdKnowledgeViewModel();
            List <ProveedoresOnLine.ThirdKnowledge.Models.TDQueryModel> oQueryModel = new List <TDQueryModel>();

            List <PlanModel> oCurrentPeriodList = new List <PlanModel>();

            oCurrentPeriodList = ProveedoresOnLine.ThirdKnowledge.Controller.ThirdKnowledgeModule.GetCurrenPeriod(SessionModel.CurrentCompany.CompanyPublicId, true);
            if (oCurrentPeriodList != null && oCurrentPeriodList.Count > 0)
            {
                oModel.RelatedThidKnowledgeSearch.CurrentPlanModel = oCurrentPeriodList.OrderByDescending(x => x.CreateDate).First();
            }

            oModel.RelatedThidKnowledgeSearch.RelatedThidKnowledgePager = new Models.ThirdKnowledge.ThirdKnowledgeSearchViewModel()
            {
                PageNumber = !string.IsNullOrEmpty(PageNumber) ? Convert.ToInt32(PageNumber) : 0,
            };
            int TotalRows = 0;

            oModel.RelatedThidKnowledgeSearch.RelatedThidKnowledgePager.PageNumber = !string.IsNullOrEmpty(PageNumber) ? Convert.ToInt32(PageNumber) : 0;

            oQueryModel = ProveedoresOnLine.ThirdKnowledge.Controller.ThirdKnowledgeModule.ThirdKnowledgeSearch(
                SessionModel.CurrentCompany.CompanyPublicId,
                !string.IsNullOrEmpty(InitDate) ? InitDate : "",
                !string.IsNullOrEmpty(EndDate) ? EndDate : "",
                oModel.RelatedThidKnowledgeSearch.RelatedThidKnowledgePager.PageNumber,
                Convert.ToInt32(MarketPlace.Models.General.InternalSettings.Instance[MarketPlace.Models.General.Constants.C_Settings_Grid_RowCountDefault].Value.Trim()),
                SearchType,
                Status,
                out TotalRows);

            oModel.RelatedThidKnowledgeSearch.RelatedThidKnowledgePager.TotalRows = TotalRows;

            if (oQueryModel != null && oQueryModel.Count > 0)
            {
                oModel.RelatedThidKnowledgeSearch.ThirdKnowledgeResult = oQueryModel.OrderByDescending(x => x.CreateDate).ToList();
            }
            else
            {
                oModel.RelatedThidKnowledgeSearch.ThirdKnowledgeResult = new List <TDQueryModel>();
            }

            oModel.ProviderMenu = GetThirdKnowledgeControllerMenu();

            return(View(oModel));
        }
コード例 #11
0
        public JsonResult CreateProvider([DataSourceRequest]  DataSourceRequest request, ProviderViewModel provider)
        {
            if (provider == null || !ModelState.IsValid)
            {
                return Json(new[] { provider }.ToDataSourceResult(request, ModelState), JsonRequestBehavior.AllowGet);
            }

            var createdProvider = this.providers.CreateProvider(provider);

            var loggedUserId = this.User.Identity.GetUserId();
            Base.CreateActivity(ActivityType.Create, createdProvider.Id.ToString(), ActivityTargetType.Provider, loggedUserId);

            provider.Id = createdProvider.Id;

            return Json(new[] { provider }.ToDataSourceResult(request, ModelState), JsonRequestBehavior.AllowGet);
        }
コード例 #12
0
        public async Task <IActionResult> Index(long?ukprn = null)
        {
            var model = new ProviderViewModel();

            if (ukprn.HasValue)
            {
                var provider = await _addNewProviderService.GetProvider(ukprn.Value);

                model.Ukprn        = provider.Ukprn;
                model.ProviderName = provider.Name;
                model.Upin         = provider.Upin;
                model.IsMca        = provider.IsMca.GetValueOrDefault();
            }

            return(View("Index", model));
        }
コード例 #13
0
        public async Task <IActionResult> Edit(Guid id, ProviderViewModel providerViewModel)
        {
            if (id != providerViewModel.Id)
            {
                return(NotFound());
            }

            if (!ModelState.IsValid)
            {
                return(View(providerViewModel));
            }

            await _providerRepository.Update(_mapper.Map <Provider>(providerViewModel));

            return(RedirectToAction(nameof(Index)));
        }
コード例 #14
0
        /// <summary>
        /// Converts viewmodel to model
        /// </summary>
        /// <param name="model">The model.</param>
        /// <returns></returns>
        public static ProviderModel ToModel(this ProviderViewModel model)
        {
            if (model == null)
            {
                return(null);
            }
            var entity = new ProviderModel
            {
                CredentialId = model.CredentialId,
                ProviderId   = model.ProviderId,
                ProviderName = model.ProviderName,
                ModifiedOn   = model.ModifiedOn
            };

            return(entity);
        }
コード例 #15
0
        public ActionResult Edit(int id)
        {
            var provider = dgrosStore.Providers.SingleOrDefault(p => p.PersonId == id);

            if (provider == null)
            {
                return(HttpNotFound());
            }
            else
            {
                var ProviderModel = new ProviderViewModel()
                {
                    Provider = provider
                };
                return(View("SaveProvider", ProviderModel));
            }
        }
コード例 #16
0
        /// <summary>
        /// Converts model to viewmodel
        /// </summary>
        /// <param name="entity">The entity.</param>
        /// <returns></returns>
        public static ProviderViewModel ToViewModel(this ProviderModel entity)
        {
            if (entity == null)
            {
                return(null);
            }

            var model = new ProviderViewModel
            {
                CredentialId = entity.CredentialId,
                ProviderId   = entity.ProviderId,
                ProviderName = entity.ProviderName,
                ModifiedOn   = entity.ModifiedOn
            };

            return(model);
        }
        public override void Given()
        {
            navigation = true;

            mockViewmodel = new ProviderViewModel()
            {
                Tlevels = new List <TlevelViewModel>()
                {
                    new TlevelViewModel {
                        TlevelTitle = "Arts", TqProviderId = 1
                    }
                },
            };

            ProviderLoader.GetViewProviderTlevelViewModelAsync(Arg.Any <long>(), providerId)
            .Returns(mockViewmodel);
        }
コード例 #18
0
        public async Task <ActionResult> Update(Guid id, ProviderViewModel providerViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(OkResult(ModelState));
            }

            if (!await _applicationServideProvider.ExistsProvider(id))
            {
                Notify("Fornecedor não encontrato");
                return(OkResult());
            }

            await _applicationServideProvider.UpdateAsync(providerViewModel);

            return(OkResult());
        }
コード例 #19
0
        public async Task <ActionResult <ProviderViewModel> > Update(Guid id, ProviderViewModel providerViewModel)
        {
            if (id != providerViewModel.Id)
            {
                NotifierError("The given id is different from the id passed in the query");
                return(CustomResponse(providerViewModel));
            }

            if (!ModelState.IsValid)
            {
                return(CustomResponse(providerViewModel));
            }

            await _providerService.Update(_mapper.Map <Provider>(providerViewModel));

            return(CustomResponse(providerViewModel));
        }
コード例 #20
0
 public static void UpdateProvider(this Provider provider, ProviderViewModel providerVm)
 {
     provider.ID              = providerVm.ID;
     provider.Name            = providerVm.Name;
     provider.Description     = providerVm.Description;
     provider.Alias           = providerVm.Alias;
     provider.DisplayOrder    = providerVm.DisplayOrder;
     provider.Image           = providerVm.Image;
     provider.HomeFlag        = providerVm.HomeFlag;
     provider.CreatedDate     = providerVm.CreatedDate;
     provider.CreatedBy       = providerVm.CreatedBy;
     provider.UpdatedDate     = providerVm.UpdatedDate;
     provider.UpdatedBy       = providerVm.UpdatedBy;
     provider.MetaKeyword     = providerVm.MetaKeyword;
     provider.MetaDescription = providerVm.MetaDescription;
     provider.Status          = providerVm.Status;
 }
コード例 #21
0
        public ActionResult CreateUpdateProvider(ProviderViewModel provider)
        {
            var nuser = new User();

            try
            {
                nuser         = Mapper.Map <User>(provider.User);
                nuser.Surname = provider.User.Name;


                if (provider.Id == 0)
                {
                    nuser = this.UserService.CreateUser(nuser);

                    var nprovider = new ProviderRequest()
                    {
                        UserId  = nuser.Id,
                        Item    = provider.Item,
                        Address = Mapper.Map <Address>(provider.Address)
                    };

                    this.ProviderService.CreateProvider(nprovider);
                }
                else
                {
                    this.UserService.UpdateUser(nuser);
                    var nprovider = Mapper.Map <Provider>(provider);

                    this.ProviderService.UpdateProvider(
                        new ProviderRequest()
                    {
                        Address = nprovider.Address,
                        Id      = nprovider.Id,
                        Item    = nprovider.Item,
                        UserId  = nprovider.User.Id
                    });
                }

                return(Redirect("/Providers/Index"));
            }
            catch (Exception ex)
            {
                return(View("../Shared/Error"));
            }
        }
コード例 #22
0
        public async Task <ActionResult> UpdateAsync(Guid id, ProviderViewModel providerViewModel)
        {
            var provider = await _applicationServiceProvider.GetByIdAsync(id);

            if (provider == null)
            {
                return(BadRequest());
            }

            if (provider.Id != providerViewModel.Id)
            {
                return(BadRequest());
            }

            await _applicationServiceProvider.UpdateAsync(providerViewModel);

            return(Ok());
        }
コード例 #23
0
        public async Task <IActionResult> Create(ProviderViewModel providerViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(providerViewModel));
            }

            var provider = _mapper.Map <Provider>(providerViewModel);

            await _providerService.Add(provider);

            if (!OperacaoValida())
            {
                return(View(providerViewModel));
            }

            return(RedirectToAction(nameof(Index)));
        }
コード例 #24
0
        public ActionResult Details(string id)
        {
            if (id == null)
            {
                return(HttpNotFound());
            }

            var providerProfile = userService.GetById(id);

            if (providerProfile == null)
            {
                return(HttpNotFound());
            }

            ProviderViewModel provider = new ProviderViewModel((ProviderProfile)providerProfile.UserProfile);

            return(View(provider));
        }
コード例 #25
0
        public async Task <ActionResult> Delete(int?id)
        {
            if (!id.HasValue)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            ProviderDTO providerDTO = await providerService.GetAsync(id.Value);

            if (providerDTO == null)
            {
                return(HttpNotFound());
            }

            ProviderViewModel providerView = Mapper.Map <ProviderViewModel>(providerDTO);

            return(PartialView(providerView));
        }
        public override void Given()
        {
            mockViewmodel = new ProviderViewModel
            {
                Tlevels = new List <TlevelViewModel>
                {
                    new TlevelViewModel {
                        TlevelTitle = "Design: Construction"
                    },
                    new TlevelViewModel {
                        TlevelTitle = "Arts"
                    },
                },
            };

            ProviderLoader.GetViewProviderTlevelViewModelAsync(Arg.Any <long>(), providerId)
            .Returns(mockViewmodel);
        }
コード例 #27
0
        public ActionResult Upsert(ProviderViewModel model)
        {
            if (!ModelState.IsValid)
            {
                InitUpsertBreadcrumb(model);
                return(View(model));
            }

            using (var transaction = ContextManager.NewTransaction())
            {
                model.Id = providerService.Upsert(Mapper.Map <Provider>(model));
                transaction.Commit();
            }

            this.ShowMessage(MessageType.Success, Resource.ChangesSuccessfullySaved);
            return(RedirectToAction("Index", new ProviderQueryModel {
                Id = model.Id
            }));
        }
コード例 #28
0
 public ActionResult Edit(int id, ProviderViewModel collection)
 {
     try
     {
         if (id > 0)
         {
             if (ModelState.IsValid)
             {
                 var model = _mapper.Map <User>(collection);
                 model.UpdaterId = LogedInAdmin.Id;
                 _providerService.Update(model);
                 var activity = new Activity
                 {
                     ActionTypeId = (byte)GeneralEnums.ActionType.Edit,
                     CreatorId    = LogedInAdmin.Id,
                     EntityId     = model.Id,
                     EntityTypeId = (byte)GeneralEnums.EntityType.User,
                     Data         = "{\"User\":" + JsonConvert.SerializeObject(model, Formatting.None) + "}"
                 };
                 _activityService.Insert(activity);
                 return(RedirectToAction("Index"));
             }
             ModelState.AddModelError(string.Empty, GeneralMessages.DefectiveEntry);
         }
         else
         {
             ModelState.AddModelError(string.Empty, GeneralMessages.EmptyId);
         }
     }
     catch (Exception ex)
     {
         _logger.Error(ex);
         if (ex.InnerException != null && ex.InnerException.Source.Equals(GeneralMessages.ExceptionSource))
         {
             ModelState.AddModelError(string.Empty, ex.Message);
         }
         else
         {
             ModelState.AddModelError(string.Empty, GeneralMessages.UnexpectedError);
         }
     }
     return(View(collection));
 }
コード例 #29
0
        public static ProviderViewModel Convert(this Provider provider)
        {
            if (provider == null)
            {
                return(new ProviderViewModel());
            }

            var viewModel = new ProviderViewModel
            {
                ProviderId         = provider.ProviderId,
                Ukprn              = provider.Ukprn,
                FullName           = provider.FullName,
                TradingName        = provider.TradingName,
                IsMigrated         = provider.IsMigrated,
                ProviderStatusType = provider.ProviderStatusType,
            };

            return(viewModel);
        }
コード例 #30
0
        public async Task <IActionResult> Create(ProviderViewModel providerViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(providerViewModel));
            }

            var provider = _mapper.Map <Provider>(providerViewModel);
            await _providerService.Add(provider);

            if (!ValidOperation())
            {
                return(View(providerViewModel));
            }

            TempData["Success"] = "Provider successfully created.";

            return(RedirectToAction("Index"));
        }
コード例 #31
0
        public async Task <Provider> Edit(ProviderViewModel model)
        {
            try
            {
                var response = await client.PutProtectedAsync <HttpSingleResponse <Provider> >($"{url}/providers", model);

                if (response != null && response.IsSuccess)
                {
                    return(response.Value);
                }
                return(null);
            }
            catch (Exception ex)
            {
                //TODO: Implement error logging for future anaylysis and fixes

                return(null);
            }
        }
コード例 #32
0
        public async Task <IActionResult> EditAddress(ProviderViewModel viewModel)
        {
            ModelState.Remove("Name");
            ModelState.Remove("DocumentNumber");
            if (ModelState.IsValid)
            {
                await _providerService.UpdateAddress(_mapper.Map <Address>(viewModel.Address));

                if (!ValidOperation())
                {
                    return(PartialView("_UpdateAddress", viewModel));
                }

                var url = Url.Action("GetAddress", "Providers", new { providerId = viewModel.Address.ProviderId });
                return(Json(new { success = true, url }));
            }

            return(PartialView("_UpdateAddress", viewModel));
        }
コード例 #33
0
        public async Task <IActionResult> SelectImapProvider()
        {
            var userId = User.FindFirst(ClaimTypes.NameIdentifier)?.Value;

            if (userId == null)
            {
                throw new ApplicationException($"User ID was not found in user claims!");
            }

            var user = await _dbContext.Users
                       .Include(appUser => appUser.ImapConfigurations)
                       .Include(appUser => appUser.SmtpConfigurations)
                       .SingleOrDefaultAsync(appUser => appUser.Id == userId);

            var model = new ProviderViewModel();

            var firstImapConf = user.ImapConfigurations.FirstOrDefault();

            if (firstImapConf != null)
            {
                model.imaphost = firstImapConf.Host;
                model.imapport = firstImapConf.Port;
                model.login    = firstImapConf.Login;
                model.password = firstImapConf.Password;
                model.useSsl   = firstImapConf.UseSsl;
            }

            var firstSmtpConf = user.SmtpConfigurations.FirstOrDefault();

            if (firstSmtpConf != null)
            {
                model.smtphost = firstSmtpConf.Host;
                model.smtpport = firstSmtpConf.Port;
                // some overriding here - ProviderViewModel assumes that
                // IMAP and SMPT shares password and SSL settings
                model.login    = firstSmtpConf.Username;
                model.password = firstSmtpConf.Password;
                model.useSsl   = firstImapConf.UseSsl;
            }

            return(View(model));
        }
コード例 #34
0
        public ProviderViewModel CreateProvider(ProviderViewModel provider)
        {
            var newProvider = new Provider()
            {
                Name = provider.Name,
                TypeOfCompany = provider.TypeOfCompany,
                Uic = provider.Uic,
                Vat = provider.Vat,
                BankAccount = provider.BankAccount,
                ResidenceAndAddress = provider.ResidenceAndAddress,
                NetworkPage = provider.NetworkPage,
                ContactPerson = provider.ContactPerson,
                PhoneNumber = provider.PhoneNumber,
                Email = provider.Email,
                Address = provider.Address,
                Term = provider.Term,
                Cps = provider.Cps,
                Commission = provider.Commission,
                Comments = provider.Comments,
                ContractTemplate = provider.ContractTemplate,
                Channels = new List<Channel>(),
                Contracts = new List<ProviderContract>(),
                Discussions = new List<Discussion>(),
                IsVisible = provider.IsVisible
            };

            if (string.IsNullOrEmpty(provider.LogoLink) && string.IsNullOrEmpty(newProvider.LogoLink))
            {
                newProvider.LogoLink = "#";
            }
            else
            {
                newProvider.LogoLink = provider.LogoLink;
            }

            this.Data.Providers.Add(newProvider);
            this.Data.SaveChanges();

            provider.Id = newProvider.Id;

            return provider;
        }
コード例 #35
0
        public ProviderViewModel UpdateProvider(ProviderViewModel provider)
        {
            var providerFromDb = this.Data.Providers.All()
                   .FirstOrDefault(p => p.Id == provider.Id);

            providerFromDb.Name = provider.Name;
            providerFromDb.TypeOfCompany = provider.TypeOfCompany;
            providerFromDb.Uic = provider.Uic;
            providerFromDb.Vat = provider.Vat;
            providerFromDb.BankAccount = provider.BankAccount;
            providerFromDb.ResidenceAndAddress = provider.ResidenceAndAddress;
            providerFromDb.NetworkPage = provider.NetworkPage;
            providerFromDb.ContactPerson = provider.ContactPerson;
            providerFromDb.PhoneNumber = provider.PhoneNumber;
            providerFromDb.Email = provider.Email;
            providerFromDb.Address = provider.Address;
            providerFromDb.Term = provider.Term;
            providerFromDb.Cps = provider.Cps;
            providerFromDb.Commission = provider.Commission;
            providerFromDb.LogoLink = provider.LogoLink;
            providerFromDb.Comments = provider.Comments;
            providerFromDb.ContractTemplate = provider.ContractTemplate;
            providerFromDb.IsVisible = provider.IsVisible;

            if (string.IsNullOrEmpty(provider.LogoLink) && string.IsNullOrEmpty(provider.LogoLink))
            {
                providerFromDb.LogoLink = "#";
            }
            else
            {
                providerFromDb.LogoLink = provider.LogoLink;
            }

            this.Data.SaveChanges();

            return provider;
        }