Exemplo n.º 1
0
 public void Post([FromBody] Section prod)
 {
     if (ModelState.IsValid)
     {
         sectionRepository.Add(prod);
     }
 }
Exemplo n.º 2
0
        public async Task AddSection_AddsToDb()
        {
            // Act
            var lResult = await sectionRepository.Add(new Entities.SectionEntity {
                SalonYear = EntitiesHelper.GetSalonYear(), SectionType = EntitiesHelper.GetSectionType()
            });

            // Assert
            Assert.IsTrue(lResult.Id > 0);
            var lCreatedEntity = await sectionRepository.GetById(lResult.Id);

            Assert.IsNotNull(lCreatedEntity);
            Assert.IsTrue(lCreatedEntity.Id > 0);
        }
Exemplo n.º 3
0
        public ActionResult Create(Section entry)
        {
            bool hasPermissions = sectionRpstry.GetPermission(sectionName, loggedUser.UserId, canCreate);

            if (hasPermissions)
            {
                try
                {
                    entry.dateCreated  = DateTime.Now;
                    entry.dateModified = DateTime.Now;
                    entry.priority     = rpstry.GetMaxPriority() + 1;
                    rpstry.Add(entry);
                    rpstry.Save();

                    #region Manage Permissions
                    var allPermissions = Request.Form.AllKeys.Where(n => n.StartsWith("permission_"));
                    rpstry.DeleteAllBySection(entry.id);
                    rpstry.Save();
                    foreach (var item in allPermissions)
                    {
                        int      roleId             = Convert.ToInt32(item.ToString().Replace("permission_", ""));
                        string[] permissiontypesIds = Request.Form.GetValues(item.ToString());
                        rpstry.ManagePermissions(entry.id, roleId, permissiontypesIds);
                    }
                    #endregion

                    return(RedirectToAction("Index", new { thisid = entry.id }));
                }
                catch (Exception e)
                {
                    ModelState.AddModelError("", "");
                    return(View(entry));
                }
            }
            else
            {
                return(View("Error", "You do not have permissions to access this section."));
            }
        }
 public void TestFindSectionByName()
 {
     sectionRepository.Add(section);
     Assert.AreEqual(sectionRepository.FindSectionByName("Test").Room, "Test room");
     sectionRepository.Delete(section);
 }