예제 #1
0
        public async Task OnPostDeleteCalificaciones_VerSiRealmenteBorra()
        {
            // Arrange
            //Preparamos un contexto que guarde la base de datos en memoria ram.
            var OptionsBuilder = new DbContextOptionsBuilder <IdentityContext>()
                                 .UseInMemoryDatabase("InMemoryDb");

            IdentityContext TestIdentityContext = new IdentityContext(OptionsBuilder.Options);
            Calificacion    Calificacion        = new Calificacion()
            {
                ID = 1, Nota = 5, Descripcion = "Descripcion de prueba"
            };

            //Guardamos una calificacion en bd
            TestIdentityContext.Calificacion.Add(Calificacion);
            await TestIdentityContext.SaveChangesAsync();


            // Act
            //Creamos una pagina de tipo DeleteModel (de Calificaciones), la cual es la que se encarga de la logica
            //de borrar calificaciones en bd.
            DeleteModel pageDeleteModel = new DeleteModel(TestIdentityContext);

            //Simulamos un post que envíe el formulario de la pagina y por ende borre en bd la calificacion que ingresamos en bd anteriormente
            await pageDeleteModel.OnPostAsync(Calificacion.ID);

            // Assert
            //Buscamos si aún esta en bd la calificacion que debió haber sido borrada por la pagina
            Calificacion CalificacionRecibida = await TestIdentityContext.Calificacion.FindAsync(Calificacion.ID);


            Assert.Null(CalificacionRecibida);
            //Si es Null significa que la pagina lo borro correctamente
        }
예제 #2
0
        public IActionResult DeleteFile([FromBody] DeleteModel deleteModel)
        {
            try
            {
                string path = Path.Combine(_webHostEnvironment.WebRootPath, "UploadedFiles/" + deleteModel.FileName);

                System.IO.File.SetAttributes(path, FileAttributes.Normal);
                System.IO.File.Delete(path);

                var model = new FilesModel
                {
                    SystemFileNames = GetLocalFiles()
                };

                return(Json(model));
            }
            catch (Exception e)
            {
                var model = new FilesModel
                {
                    SystemFileNames = GetLocalFiles(),
                    Message         = $"Error occured whilst attempting to delete file!\nError details: {e.Message}"
                };

                return(Json(model));
            }
        }
예제 #3
0
        //-------------------------------All Delete Bill Reports of Outlet-------------------//

        public ActionResult DOutletBills()
        {
            var dataofdelete        = (from p in db.tblDeleteBillMasters select p).ToList();
            List <DeleteModel> list = new List <DeleteModel>();

            foreach (var item in dataofdelete)
            {
                DeleteModel model = new DeleteModel();
                model.Address         = item.Address;
                model.BillDate        = item.BillDate;
                model.BillingType     = item.BillingType;
                model.CustomerName    = item.CustomerName;
                model.DeleteId        = item.DeleteId;
                model.DiscountAmount  = item.DiscountAmount;
                model.NetAmount       = item.NetAmount;
                model.Outletid        = item.OutletId;
                model.ServicChargeAmt = item.ServiceCharAmt;
                model.TableNo         = Convert.ToInt32(item.TableNo);
                model.TokenNo         = Convert.ToInt32(item.TokenNo);
                model.TotalAmount     = item.TotalAmount;
                model.VatAmount       = item.VatAmount;
                model.DeleteDate      = Convert.ToDateTime(item.DeleteDate);
                list.Add(model);
            }
            return(View(list));
        }
예제 #4
0
        public IActionResult Delete(DeleteModel deleteModel, ViewEditModel viewEditModel, int id)
        {
            Galleries remove = mercyContext1.Galleries.Find(id);


            DeleteModel deleteModel1 = new DeleteModel
            {
                Id          = remove.Id,
                Name        = remove.Name,
                DeletePhoto = remove.Photo
            };

            string upload     = Path.Combine(iwebHostEnvironment.WebRootPath, "images");
            string uniqueName = Guid.NewGuid().ToString() + "_" + deleteModel.Photo.FileName;
            string filePath   = Path.Combine(upload, uniqueName);

            using (var fileStream = new FileStream(filePath, FileMode.Create))
            {
                deleteModel.Photo.CopyTo(fileStream);
            }

            var sd = Path.Combine(iwebHostEnvironment.WebRootPath, "images", deleteModel.DeletePhoto);

            if (System.IO.File.Exists(sd))
            {
                System.IO.File.Delete(sd);
            }
            mercyContext1.Galleries.Remove(remove);
            mercyContext1.SaveChanges();

            RedirectToAction("UploadInfo", "Account");

            return(View());
        }
        public IHttpActionResult stergeCont([FromBody] DeleteModel cont)
        {
            AdministratorServicies spec = new AdministratorServicies();

            spec.stergeCont(cont);
            return(Ok());
        }
예제 #6
0
        public async Task OnPostAsync_InvalidId()
        {
            // Arrange
            var client = new Client {
                Id = Random.Next()
            };
            var clients = new Mock <DbSet <Client> >();

            clients.Setup(x => x.FindAsync(client.Id)).ReturnsAsync(client);
            var context = new Mock <IConfigurationDbContext>();

            context.Setup(x => x.Clients).Returns(clients.Object);
            var delete = new DeleteModel(context.Object)
            {
                Client = new Client {
                    Id = 0
                }
            };

            // Act
            var post = await delete.OnPostAsync().ConfigureAwait(false);

            // Assert
            clients.Verify(x => x.FindAsync(client.Id), Times.Never);
            clients.Verify(x => x.Remove(client), Times.Never);
            context.Verify(x => x.SaveChangesAsync(), Times.Never);
            Assert.IsType <PageResult>(post);
        }
예제 #7
0
        public ResponseResult <bool> Delete(DeleteModel delModel)
        {
            var userService = GetService <SysUserService>();
            var result      = userService.Delete(delModel);

            return(ResponseResult <bool> .GenSuccessResponse(result));
        }
        public async Task <IActionResult> Delete(DeleteModel model)
        {
            AppUser user = await userManager.FindByEmailAsync(model.Email);

            if (user != null)
            {
                IdentityResult result = await userManager.DeleteAsync(user);

                if (result.Succeeded)
                {
                    return(RedirectToAction("Index", "Home"));
                }
                else
                {
                    foreach (var error in result.Errors)
                    {
                        ModelState.AddModelError("", error.Description);
                    }
                }
            }
            else
            {
                ModelState.AddModelError("", "User Not Found");
            }
            return(View());
        }
예제 #9
0
        public async Task OnPostAsync()
        {
            // Arrange
            var persistedGrant = new PersistedGrant {
                Key = $"{Guid.NewGuid()}"
            };
            var persistedGrants = new Mock <DbSet <PersistedGrant> >();

            persistedGrants.Setup(x => x.FindAsync(persistedGrant.Key)).ReturnsAsync(persistedGrant);
            var context = new Mock <IPersistedGrantDbContext>();

            context.Setup(x => x.PersistedGrants).Returns(persistedGrants.Object);
            var delete = new DeleteModel(context.Object)
            {
                PersistedGrant = persistedGrant
            };

            // Act
            var post = await delete.OnPostAsync().ConfigureAwait(false);

            // Assert
            persistedGrants.Verify(x => x.FindAsync(persistedGrant.Key), Times.Once);
            persistedGrants.Verify(x => x.Remove(persistedGrant), Times.Once);
            context.Verify(x => x.SaveChangesAsync(), Times.Once);
            var result = Assert.IsType <RedirectToPageResult>(post);

            Assert.Equal("./Index", result.PageName);
        }
예제 #10
0
        public override async Task <OperationResult <VoidResponse> > Delete(DeleteModel model, CancellationToken ct)
        {
            return(await Task.Run(() =>
            {
                if (!TryReconnectChain(ct))
                {
                    return new OperationResult <VoidResponse>(new AppError(LocalizationKeys.EnableConnectToBlockchain));
                }

                var keys = ToKeyArr(model.PostingKey);
                if (keys == null)
                {
                    return new OperationResult <VoidResponse>(new AppError(LocalizationKeys.WrongPrivatePostingKey));
                }

                var op = new DeleteCommentOperation(model.Author, model.Permlink);
                var resp = _operationManager.BroadcastOperationsSynchronous(keys, ct, op);

                var result = new OperationResult <VoidResponse>();
                if (!resp.IsError)
                {
                    result.Result = new VoidResponse(true);
                }
                else
                {
                    OnError(resp, result);
                }
                return result;
            }, ct));
        }
        public async Task <OperationResult <VoidResponse> > DeletePostOrComment(DeleteModel model, CancellationToken ct)
        {
            var results = Validate(model);

            if (results.Any())
            {
                return(new OperationResult <VoidResponse>(new ValidationError(results)));
            }

            if (model.IsEnableToDelete)
            {
                var operationResult = await _ditchClient.Delete(model, ct);

                if (operationResult.IsSuccess)
                {
                    if (model.IsPost)
                    {
                        Trace($"post/@{model.Author}/{model.Permlink}/delete", model.Login, operationResult.Error, $"@{model.Author}/{model.Permlink}", ct);//.Wait(5000);
                    }
                    return(operationResult);
                }
            }

            var result = await _ditchClient.CreateOrEdit(model, ct);

            if (model.IsPost)
            {
                Trace($"post/@{model.Author}/{model.Permlink}/edit", model.Login, result.Error, $"@{model.Author}/{model.Permlink}", ct);//.Wait(5000);
            }
            return(result);
        }
예제 #12
0
        public async Task OnPostAsync_InvalidKey()
        {
            // Arrange
            var persistedGrant = new PersistedGrant {
                Key = $"{Guid.NewGuid()}"
            };
            var persistedGrants = new Mock <DbSet <PersistedGrant> >();

            persistedGrants.Setup(x => x.FindAsync(persistedGrant.Key)).ReturnsAsync(persistedGrant);
            var context = new Mock <IPersistedGrantDbContext>();

            context.Setup(x => x.PersistedGrants).Returns(persistedGrants.Object);
            var delete = new DeleteModel(context.Object)
            {
                PersistedGrant = new PersistedGrant {
                    Key = string.Empty
                }
            };

            // Act
            var post = await delete.OnPostAsync().ConfigureAwait(false);

            // Assert
            persistedGrants.Verify(x => x.FindAsync(persistedGrant.Key), Times.Never);
            persistedGrants.Verify(x => x.Remove(persistedGrant), Times.Never);
            context.Verify(x => x.SaveChangesAsync(), Times.Never);
            Assert.IsType <PageResult>(post);
        }
        public IActionResult Delete([FromBody] DeleteModel deleteModel)
        {
            if (!_permissionUser.CheckAccess(PermissionsName.PushNotificationDelete))
            {
                return(AccessDeniedJson());
            }
            JsonResultHelper result = new JsonResultHelper();
            var pushNotification    = _pushNotificationRepositry.GetById(deleteModel.Id);

            if (pushNotification != null)
            {
                var userNotification = _usersNotificationRepositry.GetAll().Where(x => x.PushNotificationId == pushNotification.Id).ToList();
                userNotification.ForEach(x =>
                {
                    x.IsDeleted = true;
                    _usersNotificationRepositry.Update(x);
                });
                pushNotification.IsDeleted   = true;
                pushNotification.DeletedDate = DateTime.Now;
                pushNotification.DeletedBy   = _globalSettings.CurrentUser.Id;
                _pushNotificationRepositry.Update(pushNotification);
            }

            result.success = true;
            return(Json(result));
        }
예제 #14
0
        public async Task OnPostAsync()
        {
            // Arrange
            var client = new Client {
                Id = Random.Next()
            };
            var clients = new Mock <DbSet <Client> >();

            clients.Setup(x => x.FindAsync(client.Id)).ReturnsAsync(client);
            var context = new Mock <IConfigurationDbContext>();

            context.Setup(x => x.Clients).Returns(clients.Object);
            var delete = new DeleteModel(context.Object)
            {
                Client = client
            };

            // Act
            var post = await delete.OnPostAsync().ConfigureAwait(false);

            // Assert
            clients.Verify(x => x.FindAsync(client.Id), Times.Once);
            clients.Verify(x => x.Remove(client), Times.Once);
            context.Verify(x => x.SaveChangesAsync(), Times.Once);
            var result = Assert.IsType <RedirectToPageResult>(post);

            Assert.Equal("./Index", result.PageName);
        }
예제 #15
0
        public async Task <ActionResult <MutationResult> > DeleteAsync(string id)
        {
            var mutation = new DeleteModel {
                Id = id
            };

            return(GetResult(await _mutationsHanlder.Handle(mutation)));
        }
예제 #16
0
 public ApiResult Delete([FromBody] DeleteModel model)
 {
     _logger.LogDebug($"delete model={Newtonsoft.Json.JsonConvert.SerializeObject(model)}, userId={_userId}");
     _siteMapModifyService.DeleteSiteMapItems(
         _siteId, _userId, model.ItemId,
         model.IsDeleteAllVersions ?? false);
     return(ApiResult.Success());
 }
예제 #17
0
        public async Task DeleteNoPrimaryKeyAtAllValidOperation_Failure()
        {
            var model = new DeleteModel();

            var response = await _operations.DeleteAsync(model);

            Assert.False(response.IsSuccess);
            Assert.Equal("The Primary Partition Key is required", response.ErrorMessage);
        }
예제 #18
0
 public ActionResult Delete(DeleteModel model)
 {
     DataManager.DeleteUser(model.Login);
     if (model.Login == User.Identity.Name)
     {
         return(RedirectToAction("LogOff", "User"));
     }
     return(RedirectToAction("Index", "User"));
 }
예제 #19
0
        public bool RemoveAll(DeleteModel model)
        {
            var sql = @"UPDATE dbo.SysMenu    
		    SET DelState = 1,
            MenuState = 0,
            DelUser = @DelUser,
            DelDate = getDate()
		    WHERE Id=@Id OR FatherId=@Id"        ;

            return(this.Conn.Execute(sql, new { DelUser = model.UserId, Id = model.DelString }) > 0);
        }
예제 #20
0
        public async Task OnGet_MissingId_ReturnsNotFound()
        {
            var mockRepo  = new Mock <IFacilityRepository>();
            var pageModel = new DeleteModel(mockRepo.Object);

            var result = await pageModel.OnGetAsync(null).ConfigureAwait(false);

            result.Should().BeOfType <NotFoundResult>();
            pageModel.Id.Should().Be(Guid.Empty);
            pageModel.FacilityDetail.ShouldBeNull();
        }
        public ActionResult Index(DeleteModel deleteModel)
        {
            HttpClient hc = new HttpClient();

            hc.BaseAddress = new Uri("http://localhost:50865/api/values/");
            var deleteProfile = hc.PostAsJsonAsync <DeleteModel>("DeleteProfile", deleteModel);

            deleteProfile.Wait();
            ViewBag.message = "Profile deleted successfully..!!";
            return(View());
        }
예제 #22
0
        public virtual JsonResult Delete([FromBody] DeleteModel deleteModel, [FromServices] IRepositoryBase repository)
        {
            EntityResponseDto res = new EntityResponseDto();

            Validate(deleteModel.Ids);

            int count = repository.Delete <T>(deleteModel.Ids);

            res.Success = true;

            return(Json(res));
        }
        public ActionResult Delete([Bind(Prefix = "id")] string slug)
        {
            var entry = _blogService.GetBySlug(slug);

            var model = new DeleteModel
            {
                Title = entry.Title,
                Slug  = slug
            };

            return(View(model));
        }
예제 #24
0
        public async Task <int> DeleteUserAsync(DeleteModel model)
        {
            var retval = 0;
            var result = await _applicationDbContext.Users.FirstOrDefaultAsync(u => u.Id.ToString() == model.Id);

            if (result != null)
            {
                _applicationDbContext.Users.Remove(result);
                retval = _applicationDbContext.SaveChanges();
            }
            return(retval);
        }
예제 #25
0
        public ActionResult Delete(DeleteModel model)
        {
            var imageUrl = Services.About.GetByTitle(model.Title).ImageUrl;

            if (!string.IsNullOrWhiteSpace(imageUrl))
            {
                Uri imageUri = new Uri(imageUrl);
                Services.Image.Delete(Path.GetFileName(imageUri.LocalPath));
            }
            Services.About.Delete(model.Title);
            return(RedirectToAction("Index", "About"));
        }
예제 #26
0
 public ActionResult DeleteTheStudent(DeleteModel d)
 {
     if (!ModelState.IsValid)
     {
         return(View("Delete"));
     }
     else
     {
         SqlPoco.DeleteStudent(d.Id);
         return(RedirectToAction("Index"));
     }
 }
예제 #27
0
        public ActionResult Delete([Bind(Prefix = "id")] string slug)
        {
            var entry = Services.Entry.GetBySlug(slug);

            var model = new DeleteModel
            {
                Title = entry.Title,
                Slug = slug
            };

            return View(model);
        }
예제 #28
0
        public void OnActionExecuting(ActionExecutingContext context)
        {
            Object model = Activator.CreateInstance(_clazz);

            if (context.ActionArguments.Any(x => x.Key.Equals("deleteModel")))
            {
                DeleteModel g = (DeleteModel)context.ActionArguments.Where(x => x.Key.Equals("deleteModel")).Select(o => o.Value).FirstOrDefault();
                context.ActionArguments["deleteModel"] = new DeleteModel()
                {
                    Id = g.Id, token = g.token
                };
            }
        }
        protected override string CreateDelete(DeleteModel query)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("DELETE FROM " + query.Table);

            if (query.HasWhere)
            {
                sb.Append(CreateWhere(query.Where, false));
            }

            return(sb.ToString());
        }
예제 #30
0
        public ResponseResult <bool> Delete(DeleteModel delModel)
        {
            var idparts = delModel.DelString.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

            if (idparts.Length < 1)
            {
                return(ResponseResult <bool> .GenSuccessResponse(false));
            }
            var sysMenuPermissionService = GetService <MenuPermissionService>();
            var result = sysMenuPermissionService.Delete(delModel);

            return(ResponseResult <bool> .GenSuccessResponse(result));
        }
예제 #31
0
 public ResponseResult <bool> Delete(DeleteModel model)
 {
     try
     {
         var service  = GetService <ShipInfoService>();
         var vIsSuess = service.DeleteById(model.Id);
         return(ResponseResult <bool> .GenSuccessResponse(vIsSuess));
     }
     catch (Exception ex)
     {
         return(ResponseResult <bool> .GenFaildResponse(ex.Message));
     }
 }
예제 #32
0
		public ActionResult Delete(DeleteModel model)
		{
			var imageUrl = Services.About.GetByTitle(model.Title).ImageUrl;
			if (!string.IsNullOrWhiteSpace(imageUrl))
			{
				Uri imageUri = new Uri(imageUrl);
				Services.Image.Delete(Path.GetFileName(imageUri.LocalPath));
			}
			Services.About.Delete(model.Title);
			return RedirectToAction("Index", "About");
		}
예제 #33
0
 public ActionResult Delete(DeleteModel model)
 {
     Services.Entry.Delete(model.Slug);
     return RedirectToAction("Index", "Home");
 }