public async Task <HttpResponseMessage> DeleteAsync(UserProfileModel _param)
        {
            var Res    = Request.CreateResponse();
            var Result = new Res();

            try
            {
                if (_param != null)
                {
                    await Task.Run(() => _userProfileService.Delete(_param));

                    Result.Status     = true;
                    Result.Message    = "Xóa thành công";
                    Result.StatusCode = HttpStatusCode.OK;
                }
                else
                {
                    Result.Status     = false;
                    Result.Message    = "Xóa thất bại";
                    Result.StatusCode = HttpStatusCode.BadRequest;
                }
                Res.Content = new StringContent(JsonConvert.SerializeObject(Result));
                return(Res);
            }
            catch (Exception ex)
            {
                Result.Status     = false;
                Result.Message    = "Có lỗi xảy ra trong quá trình xóa " + ex.Message;
                Result.StatusCode = HttpStatusCode.BadRequest;
                throw new Exception(ex.Message);
            }
        }
        public void Delete_ValidId_DataDeleted(int id)
        {
            //act
            var service = new UserProfileService(_userProfileRepository.Object, _logger.Object);

            service.Delete(id);

            //assert
            Assert.DoesNotContain(_data, d => d.Id == id);
        }
        public void Delete_Entity()
        {
            this.mockRepository.Setup(x => x.Delete(It.IsAny <UserProfile>()));

            var userProfileServices = new UserProfileService(this.mockRepository.Object);

            Action act = () => userProfileServices.Delete(new UserProfile());

            act.Should().NotThrow();
        }
        public void Delete_Null()
        {
            this.mockRepository.Setup(x => x.Delete(It.IsAny <UserProfile>())).Throws <NullReferenceException>();

            var userProfileServices = new UserProfileService(this.mockRepository.Object);

            Action act = () => userProfileServices.Delete(null);

            act.Should().Throw <NullReferenceException>();
        }
        public int DeleteProfiles(List<UserProfile> Profiles)
        {
            IUserProfileService _service = new UserProfileService(_SessionFactoryConfigPath);
            int ret = 0;
            foreach (UserProfile _profile in Profiles)
            {
                if (_profile.ProfileID > 0)
                {
                    try
                    {
                        _service.Delete(_profile);
                        ret++;
                    }
                    catch (Exception ex) { }
                }
            }

            _service.CommitChanges();
            return ret;
        }
Example #6
0
        public int DeleteProfiles(List <UserProfile> Profiles)
        {
            IUserProfileService _service = new UserProfileService(_SessionFactoryConfigPath);
            int ret = 0;

            foreach (UserProfile _profile in Profiles)
            {
                if (_profile.ProfileID > 0)
                {
                    try
                    {
                        _service.Delete(_profile);
                        ret++;
                    }
                    catch (Exception ex) { }
                }
            }

            _service.CommitChanges();
            return(ret);
        }