Exemplo n.º 1
0
        public async Task <DataResult <GenusModel> > GetGenusById(int id)
        {
            try
            {
                Genus entity = await _genusRepository.GetById(id);

                if (entity == null)
                {
                    return(new DataResult <GenusModel>
                    {
                        Success = false,
                        ErrorCode = ErrorCode.NotFound,
                    });
                }

                GenusModel model = _mapper.Map(entity);

                return(new DataResult <GenusModel>
                {
                    Success = true,
                    Data = model,
                });
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, $"Problems with getting Genus by id : {id}");
                return(new DataResult <GenusModel>
                {
                    Success = false,
                    ErrorCode = ErrorCode.InternalError,
                });
            }
        }
Exemplo n.º 2
0
        public async Task <Result> UpdateGenus(int id, GenusModel model)
        {
            try
            {
                Genus entity = await _genusRepository.GetById(id);

                if (entity == null)
                {
                    return(new Result
                    {
                        Success = false,
                        ErrorCode = ErrorCode.NotFound,
                    });
                }

                return(await _genusRepository.Update(_mapper.MapUpdate(entity, model)));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, $"Problems with updating Genus by id : {id}");
                return(new DataResult <GenusModel>
                {
                    Success = false,
                    ErrorCode = ErrorCode.InternalError,
                });
            }
        }
Exemplo n.º 3
0
        public async Task <Result> DeleteGenus(int id)
        {
            try
            {
                Genus entity = await _genusRepository.GetById(id);

                if (entity == null)
                {
                    return(new Result
                    {
                        Success = false,
                        ErrorCode = ErrorCode.NotFound,
                    });
                }

                return(await _genusRepository.Delete(entity));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, $"Problems with deleting Genus by id : {id}");
                return(new Result
                {
                    Success = false,
                    ErrorCode = ErrorCode.InternalError,
                });
            }
        }
Exemplo n.º 4
0
        public async Task <DataResult <GenusModel> > CreateGenus(GenusModel model)
        {
            try
            {
                Genus entity = _mapper.MapBack(model);

                DataResult <Genus> result = await _genusRepository.Add(entity);

                return(new DataResult <GenusModel>
                {
                    Success = result.Success,
                    ErrorCode = result.ErrorCode,
                    Data = _mapper.Map(result.Data),
                });
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, $"Problems with creating Genus");
                return(new DataResult <GenusModel>
                {
                    Success = false,
                    ErrorCode = ErrorCode.InternalError,
                });
            }
        }
Exemplo n.º 5
0
 public Human(int id, string name, int location, Genus kind, string description, bool isAvailable, List <string> messages, int attackLevel, Weapon currentWeapon)
     : base(id, name, location, kind, description, isAvailable)
 {
     Messages      = messages;
     AttackLevel   = attackLevel;
     CurrentWeapon = currentWeapon;
 }
Exemplo n.º 6
0
 public void SetUp()
 {
     _repo      = new Mock <ITaxonRepository>();
     _Genera    = new Genus();
     _Genera.Id = Guid.NewGuid();
     _inq       = new GeneraInquiry(_repo.Object);
 }
Exemplo n.º 7
0
        public async Task <ActionResult <Genus> > PostGenus(Genus genus)
        {
            _context.Genuses.Add(genus);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetGenus", new { id = genus.Id }, genus));
        }
Exemplo n.º 8
0
        public IActionResult AddType(Genus type)
        {
            if (ModelState.IsValid)
            {
                var types = _context.Genus.Where(t => t.NameGenus == type.NameGenus).FirstOrDefault();

                if (types == null)
                {
                    var newType = new Genus
                    {
                        NameGenus = type.NameGenus
                    };


                    _context.Add(newType);
                    _context.SaveChanges();
                    return(RedirectToAction("InstMain"));
                }

                else
                {
                    TempData["Exist"] = "Ten typ już istnieje w bazie!";
                    return(View());
                }
            }

            else
            {
                return(View());
            }
        }
Exemplo n.º 9
0
        public GenusEditViewModel(Genus genus) : base()
        {
            DataSourceName = "taxonomy_genus";
            SpeciesGenera  = new List <Species>().AsEnumerable();

            ID = genus.ID;

            if (genus.ParentID > 0)
            {
                CurrentID   = genus.ParentID;
                CurrentName = genus.AcceptedGenus.FullName;
            }
            IsSynonym                = genus.IsSynonym;
            FamilyID                 = genus.FamilyID;
            FamilyName               = genus.FamilyName;
            FamilyFullName           = genus.FamilyFullName;
            Name                     = genus.Name;
            FullName                 = genus.FullName;
            Name                     = genus.Name;
            Authority                = genus.Authority;
            QualifyingCode           = genus.QualifyingCode;
            HybridCode               = genus.HybridCode;
            SubGenusName             = genus.SubGenusName;
            SectionName              = genus.SectionName;
            SubSectionName           = genus.SubSectionName;
            SeriesName               = genus.SeriesName;
            SubSeriesName            = genus.SubSeriesName;
            Note                     = genus.Note;
            CreatedByCooperatorID    = genus.CreatedByCooperatorID;
            CreatedByCooperatorName  = genus.CreatedByCooperatorName;
            CreatedDate              = genus.CreatedDate;
            ModifiedByCooperatorID   = genus.ModifiedByCooperatorID;
            ModifiedByCooperatorName = genus.ModifiedByCooperatorName;
            ModifiedDate             = genus.ModifiedDate;
        }
        //Todo: fix redirect if null
        public ActionResult Index(int?genusId)
        {
            ActionResult result = null;

            if (!genusId.HasValue)
            {
                return(RedirectToAction("Index"));
            }


            Genus genus = m_repo.GetGenus(genusId.Value);

            if (genus == null)
            {
                result = new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            else
            {
                SessionManager.Genus = genus;
                string url = SessionManager.RedirectUrl;

                if (!url.IsNullOrWhiteSpace())
                {
                    result = Redirect(url);
                    SessionManager.RedirectUrl = string.Empty;
                }
                else
                {
                    result = RedirectToAction("Index", "Default", new { Area = "Accessions" });
                }
            }

            return(result);
        }
Exemplo n.º 11
0
        public async Task <IActionResult> PutGenus(int id, Genus genus)
        {
            if (id != genus.Id)
            {
                return(BadRequest());
            }

            _context.Entry(genus).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!GenusExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public ActionResult Index(bool?firstLoad, int?genusId)
        {
            var user = User.Identity;

            ViewBag.IsAuth = user.IsAuthenticated;
            ViewBag.Name   = user.Name;
            var sessionGenusId = SessionManager.GetGenusId();

            if (firstLoad.HasValue && firstLoad.Value == false && !genusId.HasValue)
            {
                ViewBag.firstLoad = "false";
            }
            if (genusId.HasValue && genusId.Value != sessionGenusId)
            {
                Genus genus = m_repo.GetGenus(genusId.Value);

                if (genus != null)
                {
                    SessionManager.Genus = genus;
                    sessionGenusId       = genus.Id;
                }
            }
            ViewBag.genusId         = new SelectList(m_repo.GetAllGenera(), "Id", "Value", sessionGenusId);
            ViewBag.SelectedGenusId = sessionGenusId.GetValueOrDefault();
            return(View());
        }
Exemplo n.º 13
0
        public void Is_Not_Equal_With_Other_Types()
        {
            var t1 = new Genus();
            var t2 = new Taxon();

            Assert.IsFalse(t1.Equals(t2));
        }
Exemplo n.º 14
0
        public void DetailsHappyTest()
        {
            int?id       = 12;
            var expected = new Genus
            {
                Id   = 12,
                Name = "bananas"
            };

            var mockRepo = new Mock <IPlantBreedingRepo>();

            mockRepo.Setup(r => r.GetGenus(id.Value)).Returns(expected);

            var controller = new GeneraController(mockRepo.Object);

            var response = controller.Details(id) as ViewResult;

            Assert.IsNotNull(response);
            Assert.IsNotNull(response.Model);
            Assert.IsNotNull(response.Model as Genus);

            var actual = response.Model as Genus;

            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 15
0
        public void GETDeleteHappyTest()
        {
            int?id       = 12;
            var expected = new Genus
            {
                Id   = 12,
                Name = "bananas"
            };

            var mockRepo = new Mock <IPlantBreedingRepo>();

            mockRepo.Setup(r => r.GetGenus(id.Value)).Returns(expected);

            var controller = new GeneraController(mockRepo.Object);

            // var response = controller.Delete(id) as ViewResult;
            var response = new ViewResult();

            Assert.IsNotNull(response);
            Assert.IsNotNull(response.Model);
            Assert.IsNotNull(response.Model as Genus);

            var actual = response.Model as Genus;

            Assert.AreEqual(expected, actual);

            //this unit test is not working properly.
            Assert.IsTrue(false);
        }
Exemplo n.º 16
0
        public void FillEntity_Test()
        {
            var entity = new tblTaxon();
            var poco   = new Taxon {
                Id = Guid.NewGuid()
            };

            poco.Cultivar = "cultivar";
            var Genera = new Genus();

            Genera.Id       = Guid.NewGuid();
            poco.Genus      = Genera;
            poco.Species    = "species";
            poco.SubSpecies = "sub";
            poco.Variety    = "var";
            poco.Forma      = "fa";

            _translator.FillDataEntity(entity, poco);

            Assert.AreEqual(poco.Id, entity.Id);
            Assert.AreEqual("cultivar", entity.Cultivar);
            Assert.AreEqual(poco.Genus.Id, entity.tblGenusId);
            Assert.AreEqual("species", entity.Species);
            Assert.AreEqual("sub", entity.SubSpecies);
            Assert.AreEqual("var", entity.Variety);
            Assert.AreEqual("fa", entity.Forma);
        }
Exemplo n.º 17
0
        public void POSTEditWithBadSessionTest()
        {
            var genus = new Genus()
            {
                Id = 12, Name = "Banana", Value = "Orange"
            };
            var mockRepo = new Mock <IPlantBreedingRepo>();

            var controller = new GeneraController(mockRepo.Object);

            //Session Variable Mocking
            var httpContext = new Mock <ControllerContext>();
            var session     = new Mock <HttpSessionStateBase>();

            httpContext.Setup(t => t.HttpContext.Session).Returns(session.Object);
            httpContext.SetupGet(t => t.HttpContext.Session["genusSet"]).Returns(true);

            controller.ControllerContext = httpContext.Object;

            controller.ModelState.AddModelError("test", "play them off, keyboard cat");

            var response = controller.Edit(genus) as ViewResult;

            Assert.IsNotNull(response);
            Assert.IsNotNull(response.Model);
            Assert.IsNotNull(response.Model as Genus);

            var actual = response.Model as Genus;

            Assert.AreEqual(genus, actual);
        }
Exemplo n.º 18
0
 public Weapon(string name, bool isWand = false, bool ignoresShield = false, Genus genus = Genus.None)
 {
     this.Name          = name;
     this.IsWand        = isWand;
     this.IgnoresShield = ignoresShield;
     this.Genus         = genus;
 }
Exemplo n.º 19
0
 public Character(int id, string name, int location, Genus kind)
 {
     Id       = id;
     Name     = name;
     Location = location;
     Kind     = kind;
 }
Exemplo n.º 20
0
        public void POSTEditHappyTest()
        {
            var genus = new Genus()
            {
                Id = 12, Name = "Banana", Value = "Orange"
            };
            var mockRepo = new Mock <IPlantBreedingRepo>();

            var controller = new GeneraController(mockRepo.Object);

            //Session Variable Mocking
            var httpContext = new Mock <ControllerContext>();
            var session     = new Mock <HttpSessionStateBase>();

            httpContext.Setup(t => t.HttpContext.Session).Returns(session.Object);
            httpContext.SetupGet(t => t.HttpContext.Session["genusSet"]).Returns(true);

            controller.ControllerContext = httpContext.Object;

            var response = controller.Edit(genus) as RedirectToRouteResult;

            Assert.IsNotNull(response);
            Assert.IsNotNull(response.RouteValues);
            Assert.AreEqual("Details", response.RouteValues["action"]);
        }
        public ActionResult AddMapComponent(MapComponentViewModel mapcomp)
        {
            ActionResult result;
            Map          map = m_repo.GetMap(mapcomp.MapId);

            ViewBag.GenusId = map.GenusId;
            Genus genus = map.Genus;

            ViewBag.GenusId = genus.Id;
            ViewBag.Virus1  = genus.VirusLabel1;
            ViewBag.Virus2  = genus.VirusLabel2;
            ViewBag.Virus3  = genus.VirusLabel3;
            ViewBag.Virus4  = genus.VirusLabel4;

            if (ModelState.IsValid)
            {
                map_repo.Save(mapcomp);
                result = PartialView("_MapComponentRow", mapcomp);
            }
            else
            {
                result = PartialView("_MapComponent", mapcomp);
            }

            return(result);
        }
        public ActionResult MapBuilder(int?id)
        {
            if (!id.HasValue)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            MapBuilderViewModel vm = map_repo.GetMapBuilderViewModel(id.Value);

            if (vm == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            ViewBag.Years = vm.Years;

            Genus genus = vm.Map.Genus;

            ViewBag.GenusId = vm.Map.GenusId;
            ViewBag.Virus1  = genus.VirusLabel1;
            ViewBag.Virus2  = genus.VirusLabel2;
            ViewBag.Virus3  = genus.VirusLabel3;
            ViewBag.Virus4  = genus.VirusLabel4;

            return(View(vm));
        }
Exemplo n.º 23
0
        public void POSTDeleteHappyCase()
        {
            int id    = 12;
            var genus = new Genus
            {
                Id   = 12,
                Name = "bananas"
            };

            var mockRepo = new Mock <IPlantBreedingRepo>();

            var controller = new GeneraController(mockRepo.Object);

            //Session Variable Mocking
            var httpContext = new Mock <ControllerContext>();
            var session     = new Mock <HttpSessionStateBase>();

            httpContext.Setup(t => t.HttpContext.Session).Returns(session.Object);
            httpContext.SetupGet(t => t.HttpContext.Session["genusSet"]).Returns(true);

            controller.ControllerContext = httpContext.Object;

            //var response = controller.DeleteConfirmed(id) as RedirectToRouteResult;
            var response = new RedirectToRouteResult(new System.Web.Routing.RouteValueDictionary());

            Assert.IsNotNull(response);
            Assert.IsNotNull(response.RouteValues);
            Assert.AreEqual("Index", response.RouteValues["action"]);

            //this unit test is not working properly.
            Assert.IsTrue(false);
        }
Exemplo n.º 24
0
 public Shield(string name, uint baseDefense = 0, Genus genus = Genus.None)
 {
     this.Name        = name;
     this.BaseDefense = baseDefense;
     this.Quality     = 0;
     this.Genus       = genus;
 }
Exemplo n.º 25
0
        private void SetFamiliarGenus()
        {
            Genus genus = GenusNames[familiarGenusComboBox.SelectedItem.ToString()];

            familiar.Genus = genus;
            familiarSpell1LockedCheckBox.Checked = !familiar.Spell.HasNativeGenus();
            familiarSpell2LockedCheckBox.Checked = !familiar.Spell2.HasNativeGenus();
        }
Exemplo n.º 26
0
 public Player(int id, string name, int location, Genus kind, int lives, int attackPoints, int health, bool newPLayer)
     : base(id, name, location, kind)
 {
     _lives        = lives;
     _attackPoints = attackPoints;
     _health       = health;
     _newPlayer    = newPLayer;
 }
        private static int CalculateSpellCombatAdvantage(Spell spell, Unit defender)
        {
            Genus[] attackerElement        = { spell.Genus };
            Genus   defenderElement        = FindDefenderElement(defender);
            int     elementalAdvantages    = (int)CalculateElementalAdvantages(attackerElement, defenderElement);
            int     elementalDisadvantages = (int)CalculateElementalDisadvantages(attackerElement, defenderElement);

            return(elementalAdvantages - elementalDisadvantages);
        }
Exemplo n.º 28
0
        public async Task <ActionResult> DeleteConfirmed(Guid id)
        {
            Genus genus = await db.Genus.FindAsync(id);

            db.Genus.Remove(genus);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
        private static int CalculateNonSpellCombatAdvantage(Unit attacker, Unit defender, Spell spell, int highGround)
        {
            Genus[] attackerElements       = FindAttackerElements(attacker, spell);
            Genus   defenderElement        = FindDefenderElement(defender);
            int     elementalAdvantages    = (int)CalculateElementalAdvantages(attackerElements, defenderElement);
            int     elementalDisadvantages = (int)CalculateElementalDisadvantages(attackerElements, defenderElement);

            return(elementalAdvantages - 2 * elementalDisadvantages + highGround);
        }
Exemplo n.º 30
0
        }                // default constructor

        public Npc(int id, string name, int location, Genus kind, string description, bool isAvailable)
            : base(id, name, location, kind)
        {
            Id          = id;
            Name        = name;
            Kind        = kind;
            Location    = location;
            Description = description;
            IsAvailable = isAvailable;
        }