Beispiel #1
0
        public IActionResult Create([FromForm] DomainViewModel domain)
        {
            if (string.IsNullOrEmpty(domain.Domainname))
            {
                domain.Message = "Bitte neuen Domänennamen eingeben";

                return(View(domain));
            }

            var existingDomain = _dataContext.Domains.Where(d => d.Domainname == domain.Domainname).FirstOrDefault();

            if (null != existingDomain)
            {
                domain.Message = $"Domäne {domain.Domainname} existiert schon";

                return(View(domain));
            }

            _dataContext.Domains.Add(new Domain()
            {
                Domainname = domain.Domainname
            });
            _dataContext.SaveChanges();

            return(RedirectToAction("Index", "Domain"));
        }
Beispiel #2
0
        public IActionResult Delete([FromQuery] int id, [FromForm] DomainViewModel domain)
        {
            if (domain.Id == 0)
            {
                domain = GetDomainInfo(id);
            }

            if (domain.UserCount > 0)
            {
                domain.Message = $"Die Domäne {domain.Domainname} hat noch Benutzer!";

                return(View(domain));
            }

            if (domain.ConfirmDelete != domain.Domainname)
            {
                domain.Message = $"Der Domänen Name {domain.Domainname} stimmt nicht";

                return(View(domain));
            }

            _dataContext.Domains.Remove(_dataContext.Domains.Find(domain.Id));
            _dataContext.SaveChanges();

            return(RedirectToAction("Index", "Domain"));
        }
Beispiel #3
0
        public async Task <ActionResult> Save(DomainViewModel model)
        {
            if (model == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            if (ModelState.IsValid)
            {
                try
                {
                    Domain dto = new Domain {
                        Id = model.Id, Name = model.Name, Description = model.Description, Skills = model?.Skills
                    };
                    await domainService.SaveAsync(dto);

                    return(new HttpStatusCodeResult(HttpStatusCode.OK));
                }
                catch (DomainException ex)
                {
                    return(Json(new { Error = ex.Message }));
                }
                catch (Exception)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError));
                }
            }
            else
            {
                Response.StatusCode = (int)HttpStatusCode.BadRequest;
                return(View("AddEdit", model));
            }
        }
        public HttpResponseMessage GetWithServicesAndProceduresById(HttpRequestMessage request, int id, int airlineid = 0, string tags = "*")

        {
            Expression <Func <tbDomain, bool> > airlineidfilter, tagsfilter = null;

            if (airlineid != 0)
            {
                airlineidfilter = l => l.HospitalId == airlineid;
            }
            else
            {
                airlineidfilter = l => l.IsDeleted != true;
            }
            if (tags != "*")
            {
                tagsfilter = l => l.Tags.Contains(tags);
            }
            else
            {
                tagsfilter = l => l.IsDeleted != true;
            }
            DomainViewModel vm = new DomainViewModel()
            {
                Domain      = repo.GetWithoutTracking().Where(a => a.ID == id).FirstOrDefault(),
                ServiceInfo = serviceRepo.GetWithoutTracking().Where(a => a.DomainId == id && a.IsDeleted != true).ToList().Select(a => new ServiceViewModel()
                {
                    Procedures = procedureRepo.GetWithoutTracking().Where(b => b.ServiceID == a.ID && a.IsDeleted != true).ToList(),
                    Service    = a
                }).ToList()
            };

            HttpResponseMessage response = request.CreateResponse <DomainViewModel>(HttpStatusCode.OK, vm);

            return(response);
        }
        public string AddOrEditForDomain(DomainViewModel domainViewModel)
        {
            var hijackingDomainDto = new HijackingDomainDto();

            try
            {
                if (domainViewModel.Id != null)
                {
                    hijackingDomainDto = hijackingDomainService.GetById(domainViewModel.Id);
                }
                hijackingDomainDto.Protocol      = domainViewModel.Protocol;
                hijackingDomainDto.Domain        = domainViewModel.Domain;
                hijackingDomainDto.DestinationIp = domainViewModel.DestinationIp;
                hijackingDomainDto.CustomerId    = domainViewModel.CustomerID;
                hijackingDomainDto.Status        = (int)StatusEnum.enabled;
                hijackingDomainDto.ToStartTime   = Convert.ToDateTime(domainViewModel.ToStartTime).ToLocalTime();
                hijackingDomainDto.ToEndTime     = Convert.ToDateTime(domainViewModel.ToEndTime).ToLocalTime();
                hijackingDomainDto.Interval      = domainViewModel.Interval;
                hijackingDomainDto.Province      = domainViewModel.CheckedProvince;
                hijackingDomainDto.Isp           = domainViewModel.CheckedIsp;
                hijackingDomainDto.LastExecuted  = DateTime.Now.AddHours(-3).ToLocalTime();
                hijackingDomainDto.Redirection   = string.IsNullOrEmpty(domainViewModel.Redirection) ? "" : domainViewModel.Redirection.ToLower().Trim();

                hijackingDomainService.AddOrEdit(hijackingDomainDto);
            }
            catch (Exception ex)
            {
                log.Error(ex);
            }
            return(JsonConvert.SerializeObject(new { result = "true" }));
        }
        public ActionResult AddDomainProduct(DomainViewModel model)
        {
            TempData[SuccessAddProduct] = false;

            if (Session[ORDER_SESSION] != null)
            {
                var product = CustomerClient.GetProduct(model.ID);

                var amountProduct = new AmountProduct();
                amountProduct.Amount = 1;

                if (product.ProductType == EconomicRestClient.Models.ProductType.Domain)
                {
                    amountProduct.Product = model;
                }

                ((OrderViewModel)Session[ORDER_SESSION]).AmountProduct = amountProduct;
                TempData[SuccessAddProduct] = true;
            }
            else
            {
                return(RedirectToUmbracoPage(umbracoFailRedictPage));
            }

            return(CurrentUmbracoPage());
        }
        public async Task <IActionResult> Edit(DomainViewModel model)
        {
            MessageTitle = "Failed";
            MessageIcon  = "error";
            try
            {
                if (ModelState.IsValid)
                {
                    if (model.Type != Domain.DomainType.SLAVE)
                    {
                        var s   = _context.Records.Where(x => x.Domain_ID == model.ID && x.Type.ToUpper() == "SOA");
                        var soa = s.Single();
                        soa.TTL     = model.TTL;
                        soa.Content = $@"{model.Primary} {model.Email.Replace('@', '.')} {DateTime.Now:yyyyMMdd}{++SerialCounter:00} {model.Refresh} {model.Retry} {model.Expire} {model.TTL}";
                    }
                    Logger.Log(Logger.LogType.UPDATE,
                               JsonConvert.SerializeObject(model),
                               "Domains",
                               model.ID);
                    await _context.SaveChangesAsync();

                    MessageTitle = "Done";
                    Message      = "Domain updated successfully.";
                    MessageIcon  = "success";
                }
                else
                {
                    string errors = string.Empty;
                    foreach (var mv in ModelState.Values)
                    {
                        foreach (var error in mv.Errors)
                        {
                            errors += error.ErrorMessage + "<br>";
                        }
                    }
                    Message      = @$ "Invalid Data, {ModelState.ErrorCount} errors.<hr>Errors:{errors}";
                    MessageTitle = "Failed";
                    MessageIcon  = "error";
                }
            }
            catch (Exception ex)
            {
                Message = $@"{ex.Message}";
                if (ex.InnerException != null)
                {
                    Message += $@"<br>{ex.InnerException.Message}";
                }
                MessageTitle = "Error";
                MessageIcon  = "error";
            }
            return(new JsonResult(new Dictionary <string, string>()
            {
                { "Message", Message },
                { "Title", MessageTitle },
                { "Icon", MessageIcon }
            })
            {
                StatusCode = (MessageIcon == "error") ? 500 : 200
            });
        }
        public ActionResult InsertEdit(DomainViewModel model)
        {
            if (!ModelState.IsValid)
            {
                TempData["ErrorMessage"] = "Transaction error";
                return(RedirectToAction("Index"));
            }

            //check configuration if is possible to insert a new domain
            if (model.Operation == "I")
            {
                var canEdit = Boolean.Parse(ConfigurationManager.AppSettings["DomainEdition"]);
                if (!canEdit)
                {
                    TempData["ErrorMessage"] = "Operation forbidden";
                    return(RedirectToAction("Index"));
                }
            }
            model.ActionsList = !string.IsNullOrEmpty(model.ActionsListJson) ? JsonConvert.DeserializeObject <List <ActionEntity> >(model.ActionsListJson) : new List <ActionEntity>();
            var entity = _mapper.Map <DomainViewModel, DomainEntity>(model);

            entity.ImagePath = Server.MapPath("~/Content/img/Uploads/");
            var result = model.Operation == "E" ? _domainsManager.Update(entity) : _domainsManager.Insert(entity);

            TempData["Result"] = result;
            if (!result.Success)
            {
                return(RedirectToAction("Index"));
            }
            var operation = model.Operation == "E" ? "Edit Domain" : "Insert Domain";

            StoreLog("Domains", operation, (int)result.Entity);
            return(RedirectToAction("Edit", new{ id = (int)result.Entity }));
        }
Beispiel #9
0
        public IHttpActionResult Put(int id, [FromBody] DomainViewModel domain)
        {
            try
            {
                if (domain == null)
                {
                    return(BadRequest("Domain cannot be null"));
                }

                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }
                var updatedDomain = _repository.Update(Mapper.Map <Domain>(domain));
                if (updatedDomain == null)
                {
                    return(NotFound());
                }
                return(Ok(updatedDomain));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
Beispiel #10
0
        public static void SetViewModelValues <T>(this IBaseService <T> Service, DomainViewModel View)
            where T : BaseEntity <T>
        {
            var entity = Service.CreateServiceEntity(CreateEntityOptions.EntityEdit);

            View.UpdateModel(entity);
        }
Beispiel #11
0
        public IHttpActionResult Post([FromBody] DomainViewModel domain)
        {
            try
            {
                if (domain == null)
                {
                    return(BadRequest("Domain cannot be null"));
                }
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                var newDomain = _repository.Add(Mapper.Map <Domain>(domain));

                if (newDomain == null)
                {
                    return(Conflict());
                }
                return(Created(Request.RequestUri + newDomain.Id.ToString(), Mapper.Map <DomainViewModel>(newDomain)));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
Beispiel #12
0
        public void ConstructorShouldCreate_DomainViewModel_WithoutParams()
        {
            // Act & Assert
            var domainViewModel = new DomainViewModel();

            Assert.IsInstanceOf <DomainViewModel>(domainViewModel);
        }
        public DomainGroupCell(DomainViewModel model)
        {
            InitializeComponent();

            this.BindingContext = viewModel = model;

            this.CreateChildren();
        }
Beispiel #14
0
        public DomainViewModel UpdateDomain(int id, DomainViewModel domain)
        {
            var domainToUpdate = _domainRepository.GetById(id);

            DomainMapper.MapModelToEntity(domain, domainToUpdate);
            domainToUpdate.ModifiedBy = "TEST";
            var updatedDomain = _domainRepository.Update(domainToUpdate);

            return(DomainMapper.MapEntityToModel(updatedDomain));
        }
Beispiel #15
0
        public DomainViewModel AddDomain(DomainViewModel domain)
        {
            var domainToAdd = DomainMapper.MapModelToEntity(domain);

            domainToAdd.CreatedBy = "TEST";
            domainToAdd.SeedData  = false;
            var addedDomain = _domainRepository.Add(domainToAdd);

            return(DomainMapper.MapEntityToModel(addedDomain));
        }
        public TestSuiteMain(DomainViewModel <TestSuite, GetTestSuitesEvent, GetTestSuitesEventArgs, SelectedTestSuiteChangedEvent> viewModel)
        {
            Int64 startTicks = Log.CONSTRUCTOR("Enter", Common.LOG_CATEGORY);

            InstanceCountV++;
            InitializeComponent();

            ViewModel = viewModel;

            Log.CONSTRUCTOR("Exit", Common.LOG_CATEGORY, startTicks);
        }
        public BuildMain(DomainViewModel <Domain.Build.Build, GetBuildsEvent, GetBuildsEventArgs, SelectedBuildChangedEvent> viewModel)
        {
            Int64 startTicks = Log.CONSTRUCTOR("Enter", Common.LOG_CATEGORY);

            InstanceCountV++;
            InitializeComponent();

            ViewModel  = viewModel;
            TargetGrid = grdResults;

            Log.CONSTRUCTOR("Exit", Common.LOG_CATEGORY, startTicks);
        }
Beispiel #18
0
        public RepositoryMain(DomainViewModel <GitRepository, GetRepositoriesEvent, GetRepositoriesEventArgs, SelectedRepositoryChangedEvent> viewModel)
        {
            Int64 startTicks = Log.CONSTRUCTOR("Enter", Common.LOG_CATEGORY);

            InstanceCountV++;
            InitializeComponent();

            ViewModel  = viewModel;
            TargetGrid = grdResults;

            Log.CONSTRUCTOR("Exit", Common.LOG_CATEGORY, startTicks);
        }
Beispiel #19
0
        public GeneralSettingMain(DomainViewModel <GeneralSetting, GetGeneralSettingsEvent, GetGeneralSettingsEventArgs, SelectedGeneralSettingChangedEvent> viewModel)
        {
            Int64 startTicks = Log.CONSTRUCTOR("Enter", Common.LOG_CATEGORY);

            InstanceCountV++;
            InitializeComponent();

            ViewModel  = viewModel;
            TargetGrid = grdResults;

            Log.CONSTRUCTOR("Exit", Common.LOG_CATEGORY, startTicks);
        }
Beispiel #20
0
        //public TestPointMain(DomainViewModel<TestPoint, GetTestPointsEvent, GetTestPointsEventArgs, SelectedTestPointChangedEvent> viewModel)
        //{
        //    Int64 startTicks = Log.CONSTRUCTOR("Enter", Common.LOG_CATEGORY);

        //    InstanceCountV++;
        //    InitializeComponent();

        //    ViewModel = viewModel;
        //    TargetGrid = grdResults;

        //    Log.CONSTRUCTOR("Exit", Common.LOG_CATEGORY, startTicks);
        //}

        public TestPointMain(DomainViewModel <Value, GetTestPointsEvent, GetTestPointsEventArgs, SelectedTestPointChangedEvent> viewModel)
        {
            Int64 startTicks = Log.CONSTRUCTOR("Enter", Common.LOG_CATEGORY);

            InstanceCountV++;
            InitializeComponent();

            ViewModel  = viewModel;
            TargetGrid = grdResults;

            Log.CONSTRUCTOR("Exit", Common.LOG_CATEGORY, startTicks);
        }
        public AuthorizedResourceMain(DomainViewModel <AuthorizedResource, GetAuthorizedResourcesEvent, GetAuthorizedResourcesEventArgs, SelectedAuthorizedResourceChangedEvent> viewModel)
        {
            Int64 startTicks = Log.CONSTRUCTOR("Enter", Common.LOG_CATEGORY);

            InstanceCountV++;
            InitializeComponent();

            ViewModel  = viewModel;
            TargetGrid = grdResults;

            Log.CONSTRUCTOR("Exit", Common.LOG_CATEGORY, startTicks);
        }
Beispiel #22
0
        public PullRequestReviewerMain(DomainViewModel <PullRequestReviewer, GetPullRequestReviewersEvent, GetPullRequestReviewersEventArgs, SelectedPullRequestReviewerChangedEvent> viewModel)
        {
            Int64 startTicks = Log.CONSTRUCTOR("Enter", Common.LOG_CATEGORY);

            InstanceCountV++;
            InitializeComponent();

            ViewModel  = viewModel;
            TargetGrid = grdResults;

            Log.CONSTRUCTOR("Exit", Common.LOG_CATEGORY, startTicks);
        }
Beispiel #23
0
        public StateMain(
            DomainViewModel <State, GetStatesWITEvent, GetStatesWITEventArgs, SelectedStateWITChangedEvent> viewModel)
        {
            Int64 startTicks = Log.CONSTRUCTOR("Enter", Common.LOG_CATEGORY);

            InstanceCountV++;
            InitializeComponent();

            ViewModel  = viewModel;
            TargetGrid = grdResults;

            Log.CONSTRUCTOR("Exit", Common.LOG_CATEGORY, startTicks);
        }
Beispiel #24
0
        public WorkItemIconMain(
            DomainViewModel <WorkItemIcon, GetWorkItemIconsEvent, GetWorkItemIconsEventArgs, SelectedWorkItemIconChangedEvent> viewModel)
        {
            Int64 startTicks = Log.CONSTRUCTOR("Enter", Common.LOG_CATEGORY);

            InstanceCountV++;
            InitializeComponent();

            ViewModel  = viewModel;
            TargetGrid = grdResults;

            Log.CONSTRUCTOR("Exit", Common.LOG_CATEGORY, startTicks);
        }
Beispiel #25
0
        public ClassificationNodeMain(
            DomainViewModel <ClassificationNode, GetClassificationNodesEvent, GetClassificationNodesEventArgs, SelectedClassificationNodeChangedEvent> viewModel)
        {
            Int64 startTicks = Log.CONSTRUCTOR("Enter", Common.LOG_CATEGORY);

            InstanceCountV++;
            InitializeComponent();

            ViewModel  = viewModel;
            TargetGrid = grdResults;

            Log.CONSTRUCTOR("Exit", Common.LOG_CATEGORY, startTicks);
        }
        public BuildInfoMain(DomainViewModel <BuildInfo, GetBuildInfoEvent, GetBuildInfoEventArgs, SelectedBuildInfoChangedEvent> viewModel)
        {
            Int64 startTicks = Log.CONSTRUCTOR("Enter", Common.LOG_CATEGORY);

            InstanceCountV++;
            InitializeComponent();

            ViewModel = viewModel;
            //TargetGrid = grdResults;
            //lgTopLevel.DataContext = viewModel.Results;

            Log.CONSTRUCTOR("Exit", Common.LOG_CATEGORY, startTicks);
        }
        public async Task <IActionResult> Get(string domainName)
        {
            //procura se já tenho esse domínio no banco
            var whois  = new SearchWhois();
            var domain = await _db.SearchDomain(_db, domainName);

            //se não encontrou o domínio no banco, pesquisa no whois e salva no banco
            if (domain == null)
            {
                domain = await whois.SearchInWhoisAsync(domainName);

                if (domain.Name == "Error")
                {
                    return(BadRequest(domain.WhoIs));
                }
                _db.Domains.Add(domain);
            }

            var hora = DateTime.Now.Subtract(domain.UpdatedAt).TotalMinutes;

            //se já esgotou o ttl do domínio, preciso pesquisar novamente no whois e atualizar no banco.
            if (hora > domain.Ttl)
            {
                var domain2 = await whois.SearchInWhoisAsync(domainName);

                domain.Name      = domain2.Name;
                domain.Ip        = domain2.Ip;
                domain.UpdatedAt = DateTime.Now;
                domain.WhoIs     = domain2.WhoIs;
                domain.Ttl       = domain2.Ttl;
                domain.HostedAt  = domain2.HostedAt;
            }

            //repasso os dados do domínio para minha ViewModel
            var domainView = new DomainViewModel
            {
                Name     = domain.Name,
                Ip       = domain.Ip ?? "n/a",
                WhoIs    = domain.WhoIs,
                HostedAt = domain.HostedAt ?? "n/a"
            };

            //aguardando atualizar o banco
            await _db.SaveChangesAsync();

            //retornando a view com o domínio
            return(Ok(domainView));
        }
        public ActionResult Insert()
        {
            //check configuration if is possible to insert a new domain
            var canEdit = Boolean.Parse(ConfigurationManager.AppSettings["DomainEdition"]);

            if (!canEdit)
            {
                return(RedirectToAction("Index"));
            }
            var model = new DomainViewModel()
            {
                Operation = "I"
            };

            return(View("InsertEdit", model));
        }
Beispiel #29
0
 public IHttpActionResult Put(DomainViewModel model)
 {
     try
     {
         _uow.Domain.Verify(model.Id, this.CurrentUserId);
         return(Ok());
     }
     catch (BusinessException ex)
     {
         return(BadRequest(ex.Message));
     }
     catch (Exception ex)
     {
         _log.Error(ex);
         return(BadRequest(this.General_Err));
     }
 }
        protected void AddModel(DomainViewModel model)
        {
            var grid = new Grid();

            grid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Star)
            });
            grid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(19, GridUnitType.Star)
            });

            grid.Children.Add(new Frame()
            {
                IsVisible = false
            }, 0, 0);
            grid.Children.Add(new DomainGroupCell(model), 1, 0);
            this.StackLayout.Children.Add(grid);
        }