Exemplo n.º 1
0
        public async Task Delete_WhenSectionExists_ThenSectionIsDeleted()
        {
            Section section = new Section {
                ID = Guid.NewGuid(), Name = "Test Name"
            };

            sectionRepository.Upsert(section);
            dbContext.SaveChanges();
            sectionRepository.Delete(section);
            dbContext.SaveChanges();

            Section dbSection = await sectionRepository.GetByIDAsync(section.ID);

            Assert.IsNull(dbSection);
        }
Exemplo n.º 2
0
        /// <summary>
        /// delete a section
        /// </summary>
        /// <param name="sectionId">identifier of section</param>
        /// <returns>returns true if operation successful</returns>
        public bool DeleteSection(int sectionId)
        {
            try
            {
                FriendlyurlRepository friendlyrepo = new FriendlyurlRepository(this.session);
                SectionRepository     objsection   = new SectionRepository(this.session);
                objsection.Entity.SectionId = sectionId;
                objsection.Delete();

                friendlyrepo.Entity.Id   = sectionId;
                friendlyrepo.Entity.Type = Friendlyurl.FriendlyType.Section;
                friendlyrepo.Delete();

                Utils.InsertAudit(
                    this.session,
                    new Audit()
                {
                    Auditaction = "Delete",
                    Description = "Section -> " + sectionId.ToString(),
                    Joindate    = DateTime.Now,
                    Username    = (this.context.User as CustomPrincipal).UserId
                });

                return(true);
            }
            catch (Exception ex)
            {
                Utils.InsertLog(
                    this.session,
                    "Delete Section",
                    ex.Message + " - " + ex.StackTrace);
                return(false);
            }
        }
Exemplo n.º 3
0
        public async Task DeleteSection_RemovesFromDb()
        {
            // Arrange
            var lCreatedEntity = await sectionRepository.Add(new Entities.SectionEntity {
                SalonYear = EntitiesHelper.GetSalonYear(), SectionType = EntitiesHelper.GetSectionType()
            });

            // Act
            await sectionRepository.Delete(lCreatedEntity);

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

            Assert.IsNull(lResult);
            Assert.IsTrue(lCreatedEntity.Id > 0);
        }
Exemplo n.º 4
0
        public ActionResult Delete([DataSourceRequest] DataSourceRequest request, Section entry)
        {
            bool hasPermissions = sectionRpstry.GetPermission(sectionName, loggedUser.UserId, canDelete);

            if (hasPermissions)
            {
                try
                {
                    var realEntry = rpstry.GetBiId(entry.id);
                    rpstry.Delete(realEntry);
                    rpstry.Save();
                    return(Json(new[] { entry }.ToDataSourceResult(request, ModelState)));
                }
                catch (Exception e)
                {
                    return(Json(new[] { entry }.ToDataSourceResult(request, ModelState)));
                }
            }
            else
            {
                return(View("Error", "You do not have permissions to access this section."));
            }
        }
Exemplo n.º 5
0
 public void Delete(int sectionId)
 {
     sectionRepository.Delete(sectionId);
 }
 public void TestFindSectionByName()
 {
     sectionRepository.Add(section);
     Assert.AreEqual(sectionRepository.FindSectionByName("Test").Room, "Test room");
     sectionRepository.Delete(section);
 }
 //[AdminAuthorization]
 public IHttpActionResult DeleteSection([FromUri] int id, [FromUri] int id2)
 {
     secrepo.Delete(id2);
     return(StatusCode(HttpStatusCode.NoContent));
 }
 public JsonResult Delete(int sectionId)
 {
     return(Json(_databaseConnection.Delete(sectionId), JsonRequestBehavior.AllowGet));
 }